Resource Optimism
Definition:
This smell happens when test methods make optimistic assumptions about the existence or the state of external resources like files and databases.
This smell occurs when a test method makes an optimistic assumption that the external resource (e.g., File), utilized by the test method, exists.
Code Example:
@Test
public void saveImage_noImageFile_ko() throws IOException {
File outputFile = File.createTempFile("prefix", "png", new File("/tmp"));
ProductImage image = new ProductImage("01010101010101", ProductImageField.FRONT, outputFile);
Response response = serviceWrite.saveImage(image.getCode(), image.getField(), image.getImguploadFront(), image.getImguploadIngredients(), image.getImguploadNutrition()).execute();
assertTrue(response.isSuccess());
assertThatJson(response.body())
.node("status")
.isEqualTo("status not ok");
}
References:
Quality attributes
- Code Example
- Cause and Effect
- Frequency
- Refactoring
A preliminary evaluation on the relationship among architectural 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
Automatic Identification of High-Impact Bug Report by Product and Test Code Quality
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
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 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
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