Search code examples
junitmaven-surefire-plugin

How to display jUnit tags as a part of surefire report?


I am automating my test-cases using jUnit and I want to categorize it to some specific modules. Now, after I run the test-cases, I'm getting surefire reports. I want to filter those test-cases by the tags (i.e; login flow, registration flow) etc. I have provided the filters like below using jUnit.

@Test @Tag("LoginFlow")

Using jUnit Jupiter 5.8.2

I want to see how many test-cases are of LoginFlow and how many are of Registration flow - Based on the tags (However I can do via folder/classes, but in this requirement, I want it by Tags as we are using this tags in different folders/classes and packages)


Solution

  • If you use Allure Report instead of the default HTML reporter, the report will include any JUnit 5 tags you specify for your tests.

    Then, under most tabs (Categories, Suites, Behaviors, Packages), you can filter whatever tests you have by tag. Just type "tag: " + tag name in the search field, like this:

    filter by tag

    The JUnit Tag and Tags annotations are recognized, so you won't have to add any code.

    If you do decide to install Allure, you can then download a pre-configured empty project with JUnit 5 and Allure from Allure Start and just copy your code into the new project.

    Or you can add the allure integration to your existing project manually.