properties - How to override your Propertyfile for jUnit (maven) -


i have propertyfile config.properties in store path class loads read files. properties loaded this:

public class propertyconfig { private static final properties properties = new properties();  static {     try {         classloader loader = thread.currentthread().getcontextclassloader();         properties.load(thread.currentthread().getcontextclassloader().getresourceasstream("config.properties"));     } catch (ioexception e) {         throw new exceptionininitializererror(e);     } }  public static string getsetting(string key) {     return properties.getproperty(key); }  } 

and call in relevant class this:

private static file savedgamesfolder = new file(propertyconfig.getsetting("folder_for_saved_games")); 

for testing purposes want able change path test directory, or change whole property-file in junit-testcase. how can achieve this?

i'm using maven if helps.

assuming have config.properties in

src/main/resources/config.properties 

note: should nevertheless have properties files somewhere in src/main/resources

place test configuration in

src/main/test/config.properties 

that's it. no need change code.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -