Skip to content
Latchkey

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.

PHPUnit output
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:18

Common 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.

PHP
$this->expectNotToPerformAssertions(); // intentional, documents the choice
// or assert the actual outcome
$this->assertSame('done', $handler->process());

Align strict-mode config across environments

  1. Check beStrictAboutTestsThatDoNotTestAnything / failOnRisky in phpunit.xml.
  2. Keep the same phpunit.xml for local and CI so results match.
  3. 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.xml used by both local and CI.
  • Treat risky results as a quality signal, not noise to silence.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →