Assertion Roulette
Definition:
Occurs when a test method has multiple non-documented assertions. Multiple assertion statements in a test method without a descriptive message impacts readability/understandability/maintainability as it’s not possible to understand the reason for the failure of the test.
import unittest
airLinesCode = ['2569','2450','2340']
class Flight:
def __init__(self,airLine,mileage):
self.mileage = mileage
self.airLine = airLine
self.fullFuel = True
def isValidAirLineCode(self):
for airLineCode in airLinesCode:
if(self.airLine == airLineCode):
return True
return False
class TestFlight(unittest.TestCase):
def test_flight(self):
flight = Flight('2569',1000)
self.assertEqual(flight.mileage,1000)
self.assertTrue(flight.fullFuel)
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
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
As Code Testing: Characterizing Test Quality in Open Source Ansible Development
Assessing diffusion and perception of test smells in scala projects
Automatic Identification of High-Impact Bug Report by Product and Test Code Quality
Characterizing High-Quality Test Methods: A First Empirical Study
Detection of test smells with basic language analysis methods and its evaluation
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
Improving Student Testing Practices through a Lightweight Checklist Intervention.
Is Assertion Roulette still a test smell? An experiment from the perspective of testing education
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 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
RAIDE: a tool for Assertion Roulette and Duplicate Assert identification and refactoring
Refactoring Test Smells With JUnit 5: Why Should Developers Keep Up-to-Date?
Refactoring Test Smells: A Perspective from Open-Source Developers
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
Test-related factors and post-release defects: an empirical study
TestAXE: Automatically Refactoring Test Smells Using JUnit 5 Features
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
Understanding practitioners’ strategies to handle test smells: a multi-method study
Unit Test Smells and Accuracy of Software Engineering Student Test Suites