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

@DisplayName annotation on Test not recognized #21

Open
ShahBinoy opened this issue Jan 12, 2018 · 2 comments
Open

@DisplayName annotation on Test not recognized #21

ShahBinoy opened this issue Jan 12, 2018 · 2 comments

Comments

@ShahBinoy
Copy link

ShahBinoy commented Jan 12, 2018

Once nice feature of JUnit 5 is overriding the outputs of test Method names with more human friendly @DisplayName annotation.

Seemingly the test output does not pick up the test names from @DisplayName but rather just shows the actual method name. Our actual method names are pretty long and not display friendly. The test result xml files should use the @DisplayName annotation.

@ennru
Copy link
Contributor

ennru commented Dec 11, 2018

I see you did something about this in your fork
Did you propose the change as a pull request, @ShahBinoy?

@maichler
Copy link
Contributor

While at it, would you fix #21 as well?

It's one thing to use @DisplayName for output rendering to the console, in fact TreePrintingTestListener supports this since the beginning (e.g. by running testOnly * -- "--display-mode=tree" or configuring test options testOptions += Tests.Argument(jupiterTestFramework, "--display-mode=tree").

Support in FlatPrintingTestListener could be done, I guess.

However, this is is about rendering to XML reporting files which is a totally different story.

JUnitXmlTestsListener is what generates those XML files. It receives the same test Events which SBT uses internally to identify tests and modifies the names (which are expected to be a fully qualified class name).

e.selector match {
   case selector: TestSelector => selector.testName.split('.').last
   case nested: NestedTestSelector => nested.suiteId().split('.').last + "." + nested.testName()
   case other => s"(It is not a test it is a ${other.getClass.getCanonicalName})"
}

Every test annotated with a @DisplayName containing a dot would be reported in parts only, if at all.

Then there is SBTs use of those events to identify available tests. Changing the selectors from class names to display names leads to a whole series of changes from where tests are collected to how tests are filtered.

Not sure how to proceed on this.

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