arieslab / jnose

JNose - Java TestSmells Detection
GNU General Public License v3.0
20 stars 8 forks source link

Fix Resource Optimism #23

Closed danielevalverde closed 3 years ago

luana-martins commented 3 years ago

Description. Test code that makes optimistic assumptions about the existence (or absence) and state of external resources (such as particular directories or database tables) can cause non-deterministic behavior in test outcomes. The situation where tests run fine at one time and fail miserably the other time is not a situation you want to find yourself in. Use Setup External Resource (2) to allocate and / or initialize all resources that are used.

Detection. A test method utilizes an instance of a File class without calling the exists(), isFile() or notExists() methods of the object.