将 PHPUnit 代码覆盖率与接口结合使用

发布于 2024-12-27 09:30:39 字数 162 浏览 3 评论 0原文

我正在使用 PHPUnit (3.6.7) 来测试我的应用程序并提供代码覆盖率报告,一切都已设置并按预期工作。

尽管我对实现接口的类进行了测试,但我完全覆盖了除接口之外的所有代码。报告只是说接口没有执行

有没有办法覆盖接口?或者是告诉 PHPUnit 忽略它们以实现代码覆盖率?

I'm using PHPUnit (3.6.7) to test and provide code coverage reports on my application, everything is set-up and working as expected.

I have complete coverage for all of the code except for my interfaces, even though I have tests that for classes that implement the interfaces. The report just states that the interface was not executed

Is there a way to cover the interfaces? Or is it a case of telling PHPUnit to ignore them for code coverage?

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

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

发布评论

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

评论(3

救赎№ 2025-01-03 09:30:39

您可以指定对具体类的测试覆盖父抽象类/接口的方法。

请参阅代码覆盖率分析<中的指定涵盖的方法部分/a> 手册中的章节。

在同一章中,您还将找到在代码覆盖率分析中忽略代码块或整个文件的方法。

You can specify that tests for a concrete class cover methods from parent abstract classes/interfaces.

See Specifying Covered Methods section in Code Coverage Analysis chapter in the manual.

In the same chapter you'll also find ways to ignore blocks of code or entire files from code coverage analysis.

愁杀 2025-01-03 09:30:39

正如一个附加答案:

PHPUnit 的下一个版本(3.7.)将默认忽略覆盖的所有接口。

因此,无需使用任何类型的包含或 //@codeCoverageIgnore 方法来解决此问题。

Just as an additional answer:

The next release of PHPUnit (3.7.) will ignore all interfaces for coverage by default.

So it will not necessary to use any sort of includes or //@codeCoverageIgnore ways to work around then.

牵强ㄟ 2025-01-03 09:30:39

接口不包含可执行代码,因此没有什么可测试的。

Interfaces contain no executable code, so there's nothing there to test.

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