Phpunit tests gives warning no tests found in class

Annotations are the answer.

/** @test */
public function it_tests_something()
{
  ...
}

Adding that @test tells phpunit to treat the function as a test, regardless of the name.


The only methods that PHPUnit will recognize as tests are those with names starting with test.

So you should rename the it_fetches_posts() method to test_it_fetches_posts or testItFetchesPosts. The camel case naming is optional but useful if you use the --testdox option later.

Also, as stated in other answer you can also add the @test annotation to any method and it will be considered a test by PHPUnit.


Either begin its name with word 'test' like test_something_should_work or update the test docs with this annotation /** @test */