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

Codewars reporter ignores @testdox annotation #4

Open
hobovsky opened this issue Nov 1, 2023 · 4 comments
Open

Codewars reporter ignores @testdox annotation #4

hobovsky opened this issue Nov 1, 2023 · 4 comments

Comments

@hobovsky
Copy link

hobovsky commented Nov 1, 2023

PHPUnit provides @testdox annotation, which allows custom titles for test classes and test methods. However, Codewars reporter emits <DESCRIBE::> and <IT::> which do not use custom titles.

The cause can be that the CW reporter uses $test->getName(), while custom titles seem to be obtained with \PHPUnit\Util\Test::describeAsString($test), as can be seen in the default reporter.

@VanessaGreene
Copy link

Escalated to CW-171

@kazk
Copy link
Member

kazk commented Dec 1, 2023

@hobovsky Can you help with the fix?

We should have some tests in this repo as well.

@hobovsky
Copy link
Author

hobovsky commented Dec 1, 2023

Sure, I will see what I can do.

@hobovsky
Copy link
Author

hobovsky commented Dec 6, 2023

After looking into the issue and runnign the setup locally, it turned out I was not completely right:

  1. The @testdox annotation is not meant to work by default, with a default reporter. It works only when phpunit is run with --testdox parameter, and meant to generate so-called "agile documentation sentences".
  2. Default reporter does not use @testdox at all, and is not able to read titles provided by the annotation.
  3. However, it is be possible to use testdox utilities in CW reporter so it would report custom titles. But it's not what the default PHPUnit reporter does. Doing so would not be a bug fix, but an extension. The problem is that the prettifying of annotated and not annotated names is coupled together, and testdox prettifier cannot be easily used only for annotated names. This causes that if the CW reporter would use the testdox prettifier, also existing suites with not annotated tests will be affected, and turned into "agile documentation sentences".

I misinterpreted docs on @testdox annotation, and incorrectly assumed that the fact that it's not used on CW is a bug in CW reporter. It is not.

I created #5 so you can see how it works. Feel free to reject if the docfx prettification of not annotated titles is not desired.

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

No branches or pull requests

3 participants