I have code that creates directories and transfer files to it. I want to unit test it. But the problem is when i run the unit test these directories are created but i don't want that. I want the code to create these directories only when its running a production environment. I have googled about this, but all search results suggest the JUnit class TemporaryFolder. But that is not what i want. I am not creating directories inside my test cases. I am just testing code that creates them. So am not sure how TemporaryFolder class can help me with that. say i have code like below
public class Util {
public File getLocation(String location) {
File result = new File(location);
if (!result.exists()) {
result.mkdirs();
}
return result;
}
}
How do i unit test such code? Every time i call util.getLocation("base/location"); The directories base/location are been created but i don't want that. They should only be created when i run the code in production environment.
Aucun commentaire:
Enregistrer un commentaire