简体   繁体   English

当我在 Laravel 中制作覆盖率报告时,PHPUnit“未执行测试”

[英]PHPUnit "no test executed" when I make a coverage report, in Laravel

I triying to make a report of a coverage of my tests and I cant because when I execute the follow command: phpunit --coverage-html C:\\Users\\user\\report.html I get the follow error:我试图报告我的测试覆盖率,但我不能,因为当我执行以下命令时: 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

I using the phpunit.xml that comes by default in Laravel.我使用 Laravel 中默认提供的 phpunit.xml。

What can be the problem?可能是什么问题?

Thanks谢谢

EDIT: I add the forceCoversAnnotation="false" attribute and the problem persits.编辑:我添加了 forceCoversAnnotation="false" 属性并且问题仍然存在。

In Laravel unit tests are located inside tests folder and they have some rules in naming in order to run them.在 Laravel 中,单元测试位于tests文件夹内,它们在命名方面有一些规则以便运行它们。

I had the same issue in the past and this is how i solved it:我过去遇到过同样的问题,这就是我解决它的方法:

1) Namespace must be Test\\Unit (or if you have a middle folder include that but always inside Tests) 1)命名空间必须是 Test\\Unit (或者如果你有一个中间文件夹,但总是在测试中)

2) the name of the function you build must start with the word test like 2) 你构建的函数名必须以test开头,比如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM