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

JUnit 5: Find a good way to represent @Nested tests in the HTML report #279

Open
janschaefer opened this issue Dec 26, 2016 · 6 comments
Open

Comments

@janschaefer
Copy link
Contributor

JUnit 5 supports nested test classes with the @Nested annotation. For JGiven this raises the question of how to represent that in the HTML report. Any ideas are welcome!

@janschaefer janschaefer changed the title JUnit 5: Find a good way to represent @Nested in the HTML report JUnit 5: Find a good way to represent @Nested tests in the HTML report Dec 26, 2016
@cirquit
Copy link
Contributor

cirquit commented Dec 27, 2016

From this example, I could think of a drop-down-on-click functionality. One would have to count the inner tests as normal scenarios, which will show up in the global summary.

The readability will probably close to zero after two nested tests, that's why I'd propose hiding per default.

@janschaefer
Copy link
Contributor Author

I am not sure I understood what you mean by drop-down-on-click functionality. In any case, the current design of JGiven does not really allow for hierarchical contexts. Neither in the JSON model nor in the HTML report.

@janschaefer janschaefer modified the milestones: v0.15.0, v0.16.0 Dec 29, 2016
@ahus1
Copy link
Contributor

ahus1 commented Jan 2, 2017

@janschaefer - you already know that I'm fond of the hierarchic navigation on the lower left in the HTML5 report.

I would love the @Nested classes to inherit the tags of the outer class.

When browsing the classes hierarchy the the nested classes should be below parent classes.

@janschaefer
Copy link
Contributor Author

Regarding the first point: totally makes sense. Currently, it is not even possible to do otherwise ;-). Regarding the second point: I totally agree. That makes complete sense. The main question that I have is the case where you do something like described in the JUnit 5 documentation:

@DisplayName("A stack")
class TestingAStackDemo {

    @Nested
    @DisplayName("when new")
    class WhenNew {

         @Nested
         @DisplayName("after pushing an element")
         class AfterPushing {
               
              @Test
              @DisplayName("it is no longer empty")
              void isNotEmpty() {
                   assertFalse(stack.isEmpty());
              }

How should the text 'A stack - when new - after pushing an element' appear? It should not be in the navigation bar in the left, but somewhere next to the Scenario.

@ahus1
Copy link
Contributor

ahus1 commented Jan 2, 2017

I see. Maybe start with concatenation?

I remember that Jasmine has a history of nesting tests. See the end of the page for the executed tests - https://jasmine.github.io/2.5/introduction

Jasmine shows the "describe" and "it" in a nested hierarchy. Maybe that's something to explore?

Class (aka "describe") names refine the scenario, The methods (aka "it") describe the test. I have an example on github, but there are better ones around.

I like the "when used with" in the Jasmine examples.

@janschaefer
Copy link
Contributor Author

janschaefer commented Jan 2, 2017

Yes. Concatenation will be definitely the first implementation. Maybe the hierarchy could be implemented similar to the grouping feature of the HTML report that is already implemented. It needs only be extended to support further nesting levels.

@janschaefer janschaefer modified the milestones: v0.17.0, v0.16.0 Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants