gpt4 book ai didi

PHPUnit "no test executed"当我在 Laravel 中制作覆盖率报告时

转载 作者:行者123 更新时间:2023-12-02 04:20:20 25 4
gpt4 key购买 nike

我试图报告我的测试覆盖率,但我不能,因为当我执行以下命令时:
phpunit --coverage-html C:\Users\user\report.html
我收到以下错误:

PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\dynamic_form\phpunit.xml


Time: 0 seconds, Memory: 6.00Mb

No tests executed!

Generating code coverage report in HTML format ... done

我使用 Laravel 中默认提供的 phpunit.xml。

可能是什么问题?

谢谢

编辑:
我添加了 forceCoversAnnotation="false"属性,但问题仍然存在。

最佳答案

在 Laravel 中,单元测试位于 tests 文件夹内,它们在命名方面有一些规则以便运行它们。

我过去遇到过同样的问题,这就是我解决它的方法:

1)命名空间必须是 Test\Unit (或者如果你有一个中间文件夹,包括但总是在测试中)

2) 你构建的函数名必须以 test 这个词开头

public function testMyFunction()
{
// Put your code here
}

关于PHPUnit "no test executed"当我在 Laravel 中制作覆盖率报告时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60528708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com