Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestDox printer does not display details about exceptions raised in before-test methods - setUpBeforeClass #5976

Open
Dr-Shadow opened this issue Oct 2, 2024 · 1 comment
Labels
feature/test-runner CLI test runner feature/testdox The TextDox printer/formatter type/bug Something is broken

Comments

@Dr-Shadow
Copy link

Dr-Shadow commented Oct 2, 2024

Hello,

This is the same problem highlighted in #5760 but when the throws occurs in the setUpBeforeClass static method.

I forked the repository and added another class for the tests (MyTestWithSetupBeforeClassThrows) - https://github.com/Dr-Shadow/phpunit-setupbeforeclass-exception

There could be other cases I could be missing

Case without testdox - OK

command :

php vendor/bin/phpunit tests/MyTestWithSetupBeforeClassThrows.php tests/MyTestWithSetupThrows.php

output :

PHPUnit 11.2.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.11

EE                                                                  2 / 2 (100%)

Time: 00:00.020, Memory: 6.00 MB

There were 2 errors:

1) Tests\MyTestWithSetupBeforeClassThrows
Exception: An error has ocurred!

/var/www/html/src/ClassThatThrows.php:9
/var/www/html/tests/MyTestWithSetupBeforeClassThrows.php:12

2) Tests\MyTestWithSetupThrows::test_something
Exception: An error has ocurred!

/var/www/html/src/ClassThatThrows.php:9
/var/www/html/tests/MyTestWithSetupThrows.php:12

ERRORS!
Tests: 2, Assertions: 0, Errors: 2.

Case with testdox - KO

command :

php vendor/bin/phpunit --testdox tests/MyTestWithSetupBeforeClassThrows.php tests/MyTestWithSetupThrows.php

output :

PHPUnit 11.2.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.11

EE                                                                  2 / 2 (100%)

Time: 00:00.006, Memory: 8.00 MB

My Test With Setup Throws (Tests\MyTestWithSetupThrows)
 ✘ Something
   │
   │ Exception: An error has ocurred!
   │
   │ /var/www/html/src/ClassThatThrows.php:9
   │ /var/www/html/tests/MyTestWithSetupThrows.php:12
   │

ERRORS!
Tests: 2, Assertions: 0, Errors: 2.

Problem

Exceptions thrown in setUpBeforeClass won't get displayed in the test results with --testdox

@Dr-Shadow Dr-Shadow added the type/bug Something is broken label Oct 2, 2024
@sebastianbergmann sebastianbergmann added feature/testdox The TextDox printer/formatter feature/test-runner CLI test runner labels Oct 5, 2024
@Dr-Shadow
Copy link
Author

Hello @sebastianbergmann sorry for bothering if I'm mistaken but did I miss something in my issue ?

Should I do something else than including the reproducitble tests ?

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner feature/testdox The TextDox printer/formatter type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants
@sebastianbergmann @Dr-Shadow and others