Core\Test\Summary::skipped
$summary->skipped(): intSummary::skipped() returns how many tests of the class were skipped. A test is skipped when its #[Test] attribute has skip: with a reason.
You get a Summary as the parameter of a public static method with #[AfterClass]. The test runner creates it after the last test of the class. You cannot create a Summary yourself.
A skipped test does not run, so it is not counted in passed(), failed() or flaky(). Add the four counts to get the number of tests in the class.
The examples below show a count of skipped tests, a reminder before a release, and the total number of tests in a class.
Return value
Returns int. The number of skipped tests.
Examples
A count of skipped tests
<?nvs// Shows an `#[AfterClass]` method that prints how many tests of the class were// skipped. The second test below has `skip:`, so it does not run.
use Core\Test;use Core\Test\AfterClass;use Core\Test\Summary;
class Invoice{ public static function number(int $year, int $count): string { return 'INV-' . $year . '-' . Core\Str::padStart($count . '', 4, '0'); }}
class InvoiceTest{ #[Test] public function itPadsTheCount(): void { Test::assertSame(Invoice::number(2026, 7), 'INV-2026-0007'); }
#[Test(skip: 'the credit note format is not decided yet')] public function itNumbersACreditNote(): void { Test::assertSame(Invoice::number(2026, 8), 'CN-2026-0008'); }
// `skipped()` is `1` here. #[AfterClass] public static function printSkipped(Summary $summary): void { echo $summary->class(), ': ', $summary->skipped(), " skipped\n"; }}
// This prints `INV-2026-0007`.echo Invoice::number(2026, 7), "\n";INV-2026-0007A reminder before a release
<?nvs// Shows an `#[AfterClass]` method that reminds you of skipped tests. A skipped// test checks nothing, so it is worth looking at before a release.
use Core\Test;use Core\Test\AfterClass;use Core\Test\Summary;
class Reminder{ public static function of(string $class, int $skipped): ?string { if ($skipped == 0) { return null; } return 'Before the release, check the ' . $skipped . ' skipped test(s) in ' . $class . '.'; }}
class ExportTest{ #[Test(skip: 'the PDF library is not installed on the build server')] public function itExportsAPdf(): void { Test::assertTrue(false); }
#[Test] public function itExportsACsvHeader(): void { Test::assertSame(Core\Str::join(['id', 'total'], ','), 'id,total'); }
#[AfterClass] public static function remind(Summary $summary): void { ?string $reminder = Reminder::of($summary->class(), $summary->skipped()); if ($reminder != null) { echo $reminder, "\n"; } }}
// This prints `Before the release, check the 1 skipped test(s) in ExportTest.`.echo Reminder::of('ExportTest', 1) ?? '', "\n";Before the release, check the 1 skipped test(s) in ExportTest.The total number of tests
<?nvs// Shows an `#[AfterClass]` method that prints every count and the total number of// tests in the class. The four counts together are all tests.
use Core\Test;use Core\Test\AfterClass;use Core\Test\Summary;
class Totals{ public static function line(int $passed, int $failed, int $flaky, int $skipped): string { int $total = $passed + $failed + $flaky + $skipped; return $total . ' tests: ' . $passed . ' passed, ' . $failed . ' failed, ' . $flaky . ' flaky, ' . $skipped . ' skipped'; }}
class SignupTest{ #[Test] public function itNeedsAnEmail(): void { Test::assertTrue(Core\Str::contains('ada@example.com', '@')); }
#[Test(skip: 'the captcha service has no test mode')] public function itChecksTheCaptcha(): void { Test::assertTrue(false); }
#[AfterClass] public static function printTotals(Summary $summary): void { echo Totals::line($summary->passed(), $summary->failed(), $summary->flaky(), $summary->skipped()), "\n"; }}
// This prints `10 tests: 7 passed, 1 failed, 0 flaky, 2 skipped`.echo Totals::line(7, 1, 0, 2), "\n";10 tests: 7 passed, 1 failed, 0 flaky, 2 skipped