Sensitive Equality
Definition:
Occurs when the toString method is used within a test method. Test methods verify objects by invoking the default toString() method of the object and comparing the output against an specific string. Changes to the implementation of toString() might result in failure. The correct approach is to implement a custom method within the object to perform this comparison.
Also Known As:
The Butterfly
Code Example:
@Test
public void test1() throws UnknownHostException {
String peersPacket = "F8 4E 11 F8 4B C5 36 81 " +
"CC 0A 29 82 76 5F B8 40 D8 D6 0C 25 80 FA 79 5C " +
"FC 03 13 EF DE BA 86 9D 21 94 E7 9E 7C B2 B5 22 " +
"F7 82 FF A0 39 2C BB AB 8D 1B AC 30 12 08 B1 37 " +
"E0 DE 49 98 33 4F 3B CF 73 FA 11 7E F2 13 F8 74 " +
"17 08 9F EA F8 4C 21 B0";
byte[] payload = Hex.decode(peersPacket);
byte[] ip = decodeIP4Bytes(payload, 5);
assertEquals(InetAddress.getByAddress(ip).toString(), ("/54.204.10.41"));
}
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
Characterizing High-Quality Test Methods: A First Empirical Study
Developers perception on the severity of test smells: an empirical study
Enhancing developers’ awareness on test suites’ quality with test smell summaries
Handling Test Smells in Python: Results from a Mixed-Method Study
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
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
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
To What Extent Can Code Quality be Improved by Eliminating Test Smells?
Toward static test flakiness prediction: a feasibility study