lundi 4 avril 2016

How to unit test the class that reads Properties file

I am trying to write the Junit test cases for the class that reads Properties file Here is my code:

public class PropertiesRetreiver {

private String foo = "";
private String foo1 = "";
private static String PROPERTIES_PATH ="data.properties";

public PropertiesRetreiver() throws IOException {
InputStream in = this.getClass().getResourceAsStream(PROPERTIES_PATH);
Properties properties = new Properties();
properties.load(in);
foo = properties.getProperty("foo");
foo1 = properties.getProperty("foo1");

}

public String getfoo() {
return foo;
}

public String getfoo1() {
return foo1;
}

}.

Can anyone give me idea about test case scenario I can mock and test? Thank you very much for your help.

Aucun commentaire:

Enregistrer un commentaire