The Java library that I’m currently working on can be configured with a .properties file in the classpath. Now I want to write JUnit tests that do the following:
- If the file exists, assert that the values in there are loaded.
- If the file does not exit, assert that the default values are loaded.
Is that sort of thing possible?
Yes it is possible. Create a temporary
.propertiesfile in a folder that is on your classpath for testing. Run test.In second test rename the file to something else, run test, rename file back to original name.