I have an AttributesLoader class which picks a configuration file, retrieves variables and sets it's values to objects.
Example:
if (validatePropertyValue(configuration.getString(PROPERTY_RECORD_LIMIT))) {
extractionAttributesBuilder.setRecordLimit(configuration.getInt(PROPERTY_RECORD_LIMIT));
}
Code works fine but I struggle to write test for some of the attributes. Because the code picks up a file, I have a cfg file in my src/test/resources. One of the properties is a path to a directory..
I tried doing it this way:
path=new File(AttributesLoaderTest.class.getResource("/extractPath").getPath()));
but it doesn't work because it looks for a path: new File(AttributesLoaderTest.class.getResource("/extractPath").getPath())); which is useless..
My question is:
How can I provide a path in a file to my src/test/resources directory without it being hardoced?
path=/extractPath
Aucun commentaire:
Enregistrer un commentaire