General Fixture
Definition:
Occurs when a test case fixture is too general and the test methods only access part of it. A test setup/fixture method that initializes fields that are not accessed by test methods indicates that the fixture is too generalized. A drawback of it being too general is that unnecessary work is being done when a test method is run.
Also Known As:
Badly Used Fixture
Code Example:
public void testGetFlightsByFromAirport_OneOutboundFlight() throws Exception {
setupStandardAirportsAndFlights();
FlightDto outboundFlight = findOneOutboundFlight();
// Exercise System
List flightsAtOrigin = facade.getFlightsByOriginAirport(
outboundFlight.getOriginAirportId());
// Verify Outcome
assertOnly1FlightInDtoList( "Flights at origin", outboundFlight,
flightsAtOrigin);
}
public void testGetFlightsByFromAirport_TwoOutboundFlights() throws Exception {
setupStandardAirportsAndFlights();
FlightDto[] outboundFlights = findTwoOutboundFlightsFromOneAirport();
// Exercise System
List flightsAtOrigin = facade.getFlightsByOriginAirport(
outboundFlights[0].getOriginAirportId());
// Verify Outcome
assertExactly2FlightsInDtoList( "Flights at origin", outboundFlights,
flightsAtOrigin);
}
}
References:
Quality attributes
- Code Example
- Cause and Effect
- Frequency
- Refactoring
A preliminary evaluation on the relationship among architectural and test smells
An Empirical Study into the Relationship Between Class Features and Test Smells
An Exploratory Study on the Refactoring of Unit Test Files in Android Applications
An exploratory study of the relationship between software test smells and fault-proneness
Assessing diffusion and perception of test smells in scala projects
Automatic Identification of High-Impact Bug Report by Product and Test Code Quality
Automatic Test Smell Detection Using Information Retrieval Techniques
Characterizing High-Quality Test Methods: A First Empirical Study
Enhancing developers’ awareness on test suites’ quality with test smell summaries
Handling Test Smells in Python: Results from a Mixed-Method Study
How are test smells treated in the wild? A tale of two empirical studies
Just-In-Time Test Smell Detection and Refactoring: The DARTS Project
On The Detection of Test Smells: A Metrics-Based Approach for General Fixture and Eager Test
On the Distribution of “Simple Stupid Bugs” in Unit Test Files: An Exploratory Study
On the diffusion of test smells and their relationship with test code quality of Java projects
On the distribution of test smells in open source Android applications: an exploratory study
On the interplay between software testing and evolution and its effect on program comprehension
On the test smells detection: an empirical study on the jnose test accuracy
Strategies for avoiding text fixture smells during software evolution
TestQ: Exploring Structural and Maintenance Characteristics of Unit Test Suites
The secret life of test smells-an empirical study on test smell evolution and maintenance