Eager Test
Definition:
A test case that checks or uses more than one method of the class under test. Since its introduction, this smell has been somewhat broadly defined. It is left to interpretation which method calls count towards the maximum. Either all methods invoked on the class under test could count, or only the methods invoked on the same instance under test, or only the methods of which the return value is eventually used within an assertion.
Also Known As:
The Test It All, Split Personality, Many Assertions, Multiple Assertions, The Free Ride, The One, Piggyback, Silver Bullet
Code Example:
public void testFlightMileage_asKm2() throws Exception {
// setup fixture
// exercise contructor
Flight newFlight = new Flight(validFlightNumber);
// verify constructed object
assertEquals(validFlightNumber, newFlight.number);
assertEquals("", newFlight.airlineCode);
assertNull(newFlight.airline);
// setup mileage
newFlight.setMileage(1122);
// exercise mileage translater
int actualKilometres = newFlight.getMileageAsKm();
// verify results
int expectedKilometres = 1810;
assertEquals( expectedKilometres, actualKilometres);
// now try it with a canceled flight:
newFlight.cancel();
try {
newFlight.getMileageAsKm();
fail("Expected exception");
} catch (InvalidRequestException e) {
assertEquals( "Cannot get cancelled flight mileage", e.getMessage());
}
}
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
Analyzing Test Smells Refactoring from a Developers Perspective
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
Developers perception on the severity of test smells: an empirical study
Enhancing developers’ awareness on test suites’ quality with test smell summaries
Generated Tests in the Context of Maintenance Tasks: A Series of Empirical Studies
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 diffusion of test smells and their relationship with test code quality of Java projects
On the diffusion of test smells in automatically generated test code: an empirical study
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
Pizza versus Pinsa: On the Perception and Measurability of Unit Test Code Quality
Revisiting Test Smells in Automatically Generated Tests: Limitations, Pitfalls, and Opportunities
Scented since the beginning: On the diffuseness of test smells in automatically generated test code
Smells in software test code: A survey of knowledge in industry and academia
Test code quality and its relation to issue handling performance
Test-related factors and post-release defects: an empirical study
TestQ: Exploring Structural and Maintenance Characteristics of Unit Test Suites
The Relation of Test-Related Factors to Software Quality: A Case Study on Apache Systems
The secret life of test smells-an empirical study on test smell evolution and maintenance
To What Extent Can Code Quality be Improved by Eliminating Test Smells?
Toward static test flakiness prediction: a feasibility study
Unit Test Smells and Accuracy of Software Engineering Student Test Suites