PHPUnit "Risky Test" / "This test did not perform any assertions"
PHPUnit flagged a test as "risky" - most often because it performed no assertions, left output, or interacted with global state - and a strict configuration promotes risky tests to a non-zero exit in CI.
What this error means
CI fails with risky results like "This test did not perform any assertions" even though no assertion actually failed. Locally it may only warn, because strict-mode flags differ between environments.
OK, but there were issues!
Tests: 12, Assertions: 20, Risky: 1.
1) App\Tests\HandlerTest::testProcess
This test did not perform any assertions
/app/tests/HandlerTest.php:18Common causes
A test with no assertions
A test that only exercises code without asserting anything is "risky": it cannot fail meaningfully. beStrictAboutTestsThatDoNotTestAnything turns that into a reported issue.
Strict-mode flags differ between local and CI
failOnRisky, output checking, or coverage strictness enabled in phpunit.xml makes CI fail on conditions a looser local config ignores.
How to fix it
Add a real assertion (or expectation)
Give the test something to assert - including expecting an exception or asserting no exception is thrown.
$this->expectNotToPerformAssertions(); // intentional, documents the choice
// or assert the actual outcome
$this->assertSame('done', $handler->process());Align strict-mode config across environments
- Check
beStrictAboutTestsThatDoNotTestAnything/failOnRiskyinphpunit.xml. - Keep the same
phpunit.xmlfor local and CI so results match. - Mark genuinely assertion-free tests with
expectNotToPerformAssertions().
How to prevent it
- Write at least one assertion (or an explicit no-assertion expectation) per test.
- Commit a single
phpunit.xmlused by both local and CI. - Treat risky results as a quality signal, not noise to silence.