Skip to content
Latchkey

PHPUnit: Risky Test - This Test Did Not Perform Any Assertions in CI

PHPUnit flags a test that completes without performing any assertions as "risky". With failOnRisky="true" (or --fail-on-risky), risky tests fail the build - so a test that exercises code but never asserts turns CI red.

What this error means

CI fails with "Risky" results: "This test did not perform any assertions". The tests "pass" logically but assert nothing, and the suite is configured to be strict about risky tests.

phpunit
OK, but there were issues!
Tests: 40, Assertions: 38, Risky: 2.

1) App\Tests\MailerTest::testSendDoesNotThrow
This test did not perform any assertions
# with failOnRisky=true this fails the build

Common causes

The test asserts nothing

A test that only calls code (e.g. "does not throw") without an assertion is flagged risky, because PHPUnit cannot tell it verified anything.

Strict risky configuration in CI

beStrictAboutTestsThatDoNotTestAnything / failOnRisky make these warnings fail the build, surfacing tests that were always assertion-less.

How to fix it

Add a real assertion

Assert the actual outcome instead of relying on "no exception".

php
\$result = \$this->mailer->send(\$message);
\$this->assertTrue(\$result->wasQueued());

Make "does not throw" explicit

If the point is that no exception is thrown, assert that intent so the test is not assertion-less.

php
\$this->expectNotToPerformAssertions(); // explicit, not accidental
\$this->service->boot();

Keep strict risky checks and fix the tests

  1. Identify each risky test from the report.
  2. Add a meaningful assertion or expectNotToPerformAssertions().
  3. Keep failOnRisky=true so future assertion-less tests are caught.

How to prevent it

  • Ensure every test asserts a concrete outcome.
  • Use expectNotToPerformAssertions() deliberately when that is the intent.
  • Keep failOnRisky/strict risky settings enabled to catch empty tests.

Related guides

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