eclipse 忽略 EclEmma 中单元测试的代码覆盖率
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12592881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ignore code coverage for unit tests in EclEmma
提问by David Harkness
I have configured EclEmma not to instrument my unit testswhich works fine. However, the editor still highlights the test code as not covered. I want no highlighting in unit tests because they are not instrumented to detect coverage. How can I do this?
我已经将 EclEmma 配置为不检测我的单元测试,这很好用。但是,编辑器仍然突出显示未覆盖的测试代码。我不想在单元测试中突出显示,因为它们没有检测覆盖率。我怎样才能做到这一点?
回答by Martin Matthews
I did the following steps:
我做了以下步骤:
- Go to Preferences->Java->Code Coverageand
- set the "Only path entries matching"option to
src/main/java
- 转到首选项-> Java-> 代码覆盖率和
- 将“仅路径条目匹配”选项设置为
src/main/java
It seems to work nicely.
它似乎工作得很好。
回答by David Harkness
The include/exclude filter settings in the Preferences window apply to class name/package patterns for all projects. To control the files at the folder/path level you must set it per-project.
首选项窗口中的包含/排除过滤器设置适用于所有项目的类名/包模式。要在文件夹/路径级别控制文件,您必须为每个项目设置它。
- Right-click the project
- Select Coverage As | Coverage Configurations...
- Select the project under the Junitsubtree
- Select the Coveragetab on the right
- Uncheck the folder containing your tests, e.g.,
src/test/java
- Click Apply
- Click Close(or Coverageto run immediately)
- 右键单击项目
- 选择覆盖范围为 | 覆盖配置...
- 选择Junit子树下的项目
- 选择右侧的Coverage选项卡
- 取消选中包含您的测试的文件夹,例如,
src/test/java
- 点击应用
- 单击关闭(或Coverage立即运行)
These settings will apply every time you run the coverage in the future without having to open the configuration window.
以后每次运行coverage 时都会应用这些设置,而无需打开配置窗口。