开发者

ECL Emma how to handle test resources

i wrote a unit test where i reference to a file which is located in src/test/resources. The code looks like this:

private static final String TEST_FILE = MyClass.class.getResource("").getPath() + "myfile.properties";

When i run this test within eclipse with the normal JUnit Runner everything works fine. But when i run this Test with ECL Emma the Test fails.

After some investigations i found out that the execution directory is differend. ECL Emma has its own output folder where it copies all needed ressources and then runs the tests开发者_运维技巧. But it does not copy my test file. I don't know how to fix this. I hope somebody can help me.


You could use in-place instrumentation like described here:

http://www.eclemma.org/userdoc/launching.html

Emma won't affect the classpath/copy the classfiles then.

Another alternative would be to keep you resources in a seperate resources folder (not in src/) and add this folder to the classpath.

And maybe it would be better to retrieve the File as an InputStream:

  InputStream inStream = MyClass.class.getResourceAsStream("/myfile.properties");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜