Shadowed Zoum
Shadowed Zoum

Reputation: 107

Running PHPunit in Terminal as "vendor/bin/phpunit" shows Warning No tests found in class

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

Upvotes: 1

Views: 1372

Answers (1)

Faid
Faid

Reputation: 595

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());
}

Upvotes: 1

Related Questions