To improve my quality of code, I\'ve decided to try to learn how to test my code using Unit Testing instead of my mediocre-at-best testing solutions.
I pulled my hair for 10 minutes before i decided to use --debug (good way to go by the way) to discover the simple fact that file name didn't respect the naming convention, i had an extra "s" at the end.
wrong
CreateAdminTests
right
CreateAdminTest
hope this note could help for someone
This is very late but I hope it helps someone.
I got my tests to run by using an absolute reference. folder structure [ project/tests/test.php]
my directory line looked like this ./tests/test.php
I realize this is super old, but it just happened to me too. Hopefully this will help someone.
My problem was that I forgot the '@' symbol in /** @test */
WRONG:
/** test */
function a_thread_can_be_deleted()
{
...
}
RIGHT:
/** @test */
function a_thread_can_be_deleted()
{
...
}
I had the issue of no tests being executed, even when things were set up fine.
The cause was the namespace was not the first command of the file, it was after some doc-block comments.
reverting caused phpunit to see the tests and run correctly.
For me, using phpunit --debug showed me which test it was not executing, inside, I had
$this->visit('/')
->see('Laravel');
and I think because the directory was protected with .htaccess authentication, it could not get through to visit the page
The solution for me was to take out this test (or most likely take out .htaccess authentication)
I had the same problem after PHPUnit on our virtual machines updated to version 6. Even --debug and --verbose said nothing useful, just "No tests executed". In the end it turned out that classes and namespaces were changed in the new version and it just didn't want to execute the files that contained references to old classes. The fix for me was just to replace in every test case this:
class MyTestCase extends \PHPUnit_Framework_TestCase {...}
with:
use PHPUnit\Framework\TestCase;
class MyTestCase extends TestCase {...}