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

Uses testdox prettifier for titles #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hobovsky
Copy link

@hobovsky hobovsky commented Dec 6, 2023

Implements #4

Example kumite with result: here.

Pros:

  • Understands @testdox annotation on test classes, test methods, and generated tests.

Cons:

  • Prettifies in a default testdox way also titles which are not annotated with a custom title. As a result, existing CW test suites also will be affected (note how the testZeroIsEven gets prettified despite of having no annotation).
  • Titles of <DESCRIBE::> groups of tests generated with @dataProvider seem to not respect the annotation (but this might be a bug of my implementation)

@hobovsky hobovsky marked this pull request as ready for review December 6, 2023 23:13
Copy link
Member

@kazk kazk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad the implementation is this simple.

Cons:

  • Prettifies in a default testdox way also titles which are not annotated with a custom title. As a result, existing CW test suites also will be affected (note how the testZeroIsEven gets prettified despite of having no annotation).

I think this is fine. It looks pretty simple and shouldn't break anything.

The :: in Even Or Odd Test::test Negative Even Numbers looks weird, though.

@@ -97,6 +104,7 @@ public function startTestSuite(TestSuite $suite): void
if (empty($suiteName)) {
return;
}
$suiteName = $this->prettifier->prettifyTestClass($suiteName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? prettifyTestCase($test); takes a TestCase, but prettifyTestClass takes a string?

Maybe this is causing the issue you mentioned?

  • Titles of <DESCRIBE::> groups of tests generated with @dataProvider seem to not respect the annotation (but this might be a bug of my implementation)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least that's how I read it in code of PHPUnit 9.6:

However, the bummer seems to be that PHPUnit 10 seems to change the prettifier: move it to another namespace, and rename the method to prettifyTestClassName(string $className). As a result, my reporter will break when PHPUnit gets updated :(

Copy link
Author

@hobovsky hobovsky Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The :: in Even Or Odd Test::test Negative Even Numbers looks weird, though.

I run the suite with original TestDox reporter and it seems that it avoids the weirdness by simply not showing the intermediate groups:

image

All test cases seem to be flattened, and test cases generated with @dataProvider are not grouped under a common section, while CW reporter groups them with a <DESCRIBE::>. The title is provided by TestDox prettifier, which apparently does not care much because it's not presented by the TestDox reporter anyway. This might also be a reason why "Titles of <DESCRIBE::> groups of tests generated with @dataProvider seem to not respect the annotation" - they do not respect the annotation, because these titles are not presented by the TestDox reporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants