Test Code Duplication
Definition:
This test smell normally identifies classes that contain test methods with repeated test code steps.
Also Known As:
Second Class Citizen
Code Example:
class TestFlight(unittest.TestCase):
def test_mileage_init(self):
airLine = '2569'
mileage = 1000
flight = Flight(airLine,mileage)
self.assertEqual(flight.mileage,1000)
def test_fuel_is_full(self):
airLine = '2569'
mileage = 1000
flight = Flight(airLine,mileage)
self.assertTrue(flight.fullFuel)
def test_is_valid_air_line_code(self):
airLine = '2569'
mileage = 1000
flight = Flight(airLine,mileage)
self.assertTrue(flight.isValidAirLineCode())
if __name__ == '__main__':
unittest.main(argv=['first-arg-is-ignored'], exit=False)
References:
Quality attributes
- Code Example
- Cause and Effect
- Frequency
- Refactoring
An exploratory study of the relationship between software test smells and fault-proneness
Enhancing developers’ awareness on test suites’ quality with test smell summaries
How are test smells treated in the wild? A tale of two empirical studies
LCCSS: A Similarity Metric for Identifying Similar Test Code
On the diffusion of test smells in automatically generated test code: an empirical study
On the interplay between software testing and evolution and its effect on program comprehension
Refactoring Test Smells With JUnit 5: Why Should Developers Keep Up-to-Date?
Refactoring Test Smells: A Perspective from Open-Source Developers
Test code quality and its relation to issue handling performance
TestAXE: Automatically Refactoring Test Smells Using JUnit 5 Features