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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:03:57  来源:igfitidea点击:

Ignore code coverage for unit tests in EclEmma

javaeclipsecode-coverageeclemma

提问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:

我做了以下步骤:

  1. Go to Preferences->Java->Code Coverageand
  2. set the "Only path entries matching"option to src/main/java
  1. 转到首选项-> Java-> 代码覆盖率
  2. “仅路径条目匹配”选项设置为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.

首选项窗口中的包含/排除过滤器设置适用于所有项目的类名/包模式。要在文件夹/路径级别控制文件,您必须为每个项目设置它。

  1. Right-click the project
  2. Select Coverage As | Coverage Configurations...
  3. Select the project under the Junitsubtree
  4. Select the Coveragetab on the right
  5. Uncheck the folder containing your tests, e.g., src/test/java
  6. Click Apply
  7. Click Close(or Coverageto run immediately)
  1. 右键单击项目
  2. 选择覆盖范围为 | 覆盖配置...
  3. 选择Junit树下的项目
  4. 选择右侧的Coverage选项卡
  5. 取消选中包含您的测试的文件夹,例如, src/test/java
  6. 点击应用
  7. 单击关闭(或Coverage立即运行)

These settings will apply every time you run the coverage in the future without having to open the configuration window.

以后每次运行coverage 时都会应用这些设置,而无需打开配置窗口。