查看单个类的代码覆盖率

发布于 2025-01-04 01:46:01 字数 142 浏览 4 评论 0原文

我从事一个相对较大的项目,该项目有数千个单元测试,需要“大量”时间来运行。

有时我想查看特定单元测试给出的代码覆盖率。目前我使用 Eclemma 来获取代码覆盖率,但这似乎只能为我提供整个项目的代码覆盖率。

有没有办法获得这种缩小的视图?

I work on a relatively large project that has thousands of unit tests that takes a "significant" amount of time to run.

Sometime I would like to see the code coverage that a particular unit test gives. Currently I use Eclemma to get code coverage, but this only seems to be able to give me code coverage on the entire project.

Is there a way to get this reduced view?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我很坚强 2025-01-11 01:46:01

我相信正确的答案不是使用 Clover,而是按照 @his 的建议去做。
要在覆盖模式下运行单个 JUnit 测试,只需右键单击它并选择 Context Menu >覆盖范围为> JUnit 测试

要在记录覆盖范围后仅查看受影响的类,请选择覆盖范围视图中的小三角形,然后选择“隐藏未使用的类型”。

这将过滤视图并仅显示包含“触及”类的包和项目。

I believe the correct answer is not to use Clover but to do what @his has recommended.
To run a single JUnit Tests in coverage mode simply right click it and select Context Menu > Coverage as > JUnit Test.

To see only the affected classes after the coverage has been recorded select the little triangle in the Coverage View and select "Hide unused types".

This will filter the view and shows only packages and projects that hold "touched" classes.

随波逐流 2025-01-11 01:46:01

您是否尝试过使用Clover?它可以提供与项目中的单个单元测试有关的覆盖范围详细信息。我使用它并且我喜欢它。

在eclipse上安装clover插件。

通过 eclipse 在项目上启用 eclipse 添加并运行单元测试以查看覆盖率详细信息。

Did you try using Clover? It can give coverage details pertaining to single unit test in the project. I use it and I love it.

Install the clover plugin on eclipse.

Enable the eclipse add in on the project via eclipse and run the unit tests to see the coverage details.

断爱 2025-01-11 01:46:01

如果您正在使用 Jasmine.js,您可能正在为规范文件寻找类似的内容,

xdescribe 将从执行中排除这些规范。

fdescribe 将首先执行这些规范。如果您同时拥有 fdescribe 规范,则将执行并忽略重置

If You are using Jasmine.js probably you are looking for something like this for the spec files

xdescribe will eXclude those specs from execution.

fdescribe will first execute those specs. if you have both the fdescribe specs will be executed and reset is ignored

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文