1
votes

when running vendor/bin/phpunit i received this error

$ vendor/bin/phpunit

PHPUnit 7.5.12 by Sebastian Bergmann and contributors.

.W 2 / 2 (100%)

Time: 113 ms, Memory: 12.00 MB

There was 1 warning:

1) Warning No tests found in class

and Then Tried reinstalling composer, and php unit to current version

$ vendor/bin/phpunit

PHPUnit 7.5.12 by Sebastian Bergmann and contributors.

.W 2 / 2 (100%)

Time: 113 ms, Memory: 12.00 MB

There was 1 warning:

1) Warning No tests found in class

Should show test successful

1
How is your file name and class named, please also inlcude sample class with one single test - mrhn
forgot to put the /** @test */ before the tests! Thank you, answered my question - Shadowed Zoum
you can also name your test function with test like relation_test and it will work - mrhn
@MartinHenriksen: but the test must be at the beginning of the test method name, not at then end, mustn't it? - hakre
@hakre yes i forgot, mixed it up with a place where we used /** (at)test **/ notation - mrhn

1 Answers

2
votes

Try This in your Testing Class:

/** @test **/
function your_test_func(){
   // assertion 
}

Compare with the Phpunit Documentation which give the following description of the @test annotation:

@test

As an alternative to prefixing your test method names with test, you can use the @test annotation in a method's DocBlock to mark it as a test method.

/**
 * @test
 */
public function initialBalanceShouldBe0()
{
    $this->assertEquals(0, $this->ba->getBalance());
}