Skip to content

markTestSkipped() not handled correctly when called in "before first test" method #5164

Closed
@sebastianbergmann

Description

@sebastianbergmann

ExampleTest.php

<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

final class ExampleTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        self::markTestSkipped('message');
    }
    
    public function testOne(): void
    {
    }
    
    public function testTwo(): void
    {
    }
}

Actual Output

PHPUnit 9.6.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.2

SS                                                                  2 / 2 (100%)

Time: 00:00.001, Memory: 22.41 MB

There were 2 skipped tests:

1) ExampleTest::testOne
message

/home/sb/ExampleTest.php:8

2) ExampleTest::testTwo
Test skipped because of an error in hook method

OK, but incomplete, skipped, or risky tests!
Tests: 2, Assertions: 0, Skipped: 2.

Expected Output

PHPUnit 9.6.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.2

SS                                                                  2 / 2 (100%)

Time: 00:00.001, Memory: 22.41 MB

There were 2 skipped tests:

1) ExampleTest::testOne
message

/home/sb/ExampleTest.php:8

2) ExampleTest::testTwo
message

OK, but incomplete, skipped, or risky tests!
Tests: 2, Assertions: 0, Skipped: 2.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions