4

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 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.

What can be the problem?

Thanks

EDIT: I add the forceCoversAnnotation="false" attribute and the problem persits.

5
  • 1
    Do you have any tests? Does the tests run properly without the coverage? Commented Mar 4, 2020 at 14:55
  • If the tests aren't running at all, you may also need a composer dump before phpunit is aware of any new tests. Commented Mar 4, 2020 at 15:19
  • @ChinLeung yes, I got tests and that run properly. Commented Mar 4, 2020 at 15:42
  • @JamesClarkDeveloper I run composer dump-autoload command and the problem persists Commented Mar 4, 2020 at 15:44
  • You are running an extremely old version of phpunit. In fact, it's so old that it doesn't even show on the official release history page of phpunit anymore: phpunit.de/supported-versions.html I would recommend updating to a new version. Commented Mar 5, 2020 at 10:21

1 Answer 1

1

In Laravel unit tests are located inside tests folder and they have some rules in naming in order to run them.

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)

2) the name of the function you build must start with the word test like

public function testMyFunction()
{
    // Put your code here
}
Sign up to request clarification or add additional context in comments.

2 Comments

I check that, the tests are running properly without the coverage report
the point in number 2 have to be highlighted. Today I follow tutorial on youtube, the older version of laravel and the function without 'test' prefix is do just fine, but in newer laravel (my case laravel 8) the function name must be prefixed with 'test' word, otherwise it won't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.