allure-framework / allure-java

Allure integrations for Java test frameworks
Apache License 2.0
357 stars 226 forks source link

Ability to rename classes with TestNG #438

Open sokecze opened 4 years ago

sokecze commented 4 years ago

I'm submitting a ...

What is the current behavior?

Allure groups suites into sub-suites, which, in case of TestNG, are full class names (with their packages).

What is the expected behavior?

As far as I understand, Allure has an ability to use custom class names with JUnit. In JUnit, classes can be renamed with @DisplayName annotation. In TestNG, there's no such annotation, thus, I'd like to have something like Allure's @Description annotation be applicable to class names. For example,

@Description("Class Name Without Package")
public class TestClass

What is the motivation / use case for changing the behavior?

Some projects have very long package names, which are redundant for reports.

Please tell us about your environment:

Allure version 2.8.1
Test framework testng@6.8
Allure integration allure-testng@2.13.2
Generate report using allure-maven@2.10.0

Other information

Screen Shot 2020-04-14 at 11 37 01
kathyrollo commented 4 years ago

I would think the JUnit 5 adapter is more up to date. JUnit 5 is a good turning point to move away from TestNG now.

sokecze commented 4 years ago

I would think the JUnit 5 adapter is more up to date. JUnit 5 is a good turning point to move away from TestNG now.

@kathyrollo unfortunately, JUnit 5 suites are not as flexible as in TestNG. The way suites organized in TestNG are more convenient, I think. I'd prefer to stay with TestNG with an ability to rename test classes

kathyrollo commented 4 years ago

Used TestNG for the past 3 years, I opted with simply tagging my tests correctly and passing the tags via cmdline to the maven-surefire-plugin (see "Filtering by Tags"), also more flexible for CI/CD . Removing the testng.xml was 1 less file to maintain since my switch to JUnit 5 and was rather refreshing and lightweight. They also have versatile annotations for naming tests which Allure already supports natively (see here).

Nonetheless, I understand if you would still prefer to proceed with TestNG, just thought I would share the modern flexibility of JUnit 5. It may be more apt to request this feature with TestNG instead.

Good luck!

kathyrollo commented 4 years ago

I was going over the Allure docs, it seems Allure already supports this for TestNG. You have to use the description property of the @Test annotation.

https://docs.qameta.io/allure/#_displayname_3

sokecze commented 4 years ago

@kathyrollo this doesn't work and throws [main] ERROR io.qameta.allure.AllureLifecycle - Could not update test fixture: test fixture with uuid 3c4f2e98-e994-477e-b58f-26215de9e0ab not found [main] ERROR io.qameta.allure.AllureLifecycle - Could not stop test fixture: test fixture with uuid 3c4f2e98-e994-477e-b58f-26215de9e0ab not found