ECL Emma如何处理测试资源
我编写了一个单元测试,其中引用了位于 src/test/resources 中的文件。 代码如下所示:
private static final String TEST_FILE = MyClass.class.getResource("").getPath() + "myfile.properties";
当我使用正常的 JUnit Runner 在 Eclipse 中运行此测试时,一切正常。但是当我使用 ECL Emma 运行此测试时,测试失败了。
经过一番调查,我发现执行目录不同。 ECL Emma 有自己的输出文件夹,它复制所有需要的资源,然后运行测试。但它不会复制我的测试文件。我不知道如何解决这个问题。我希望有人能帮助我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用如下所述的就地检测:
http://www.eclemma.org/userdoc/ launch.html
Emma 不会影响类路径/复制类文件。
另一种选择是将资源保存在单独的资源文件夹中(而不是在 src/ 中),并将该文件夹添加到类路径中。
也许将文件作为输入流检索会更好:
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: