allure-java icon indicating copy to clipboard operation
allure-java copied to clipboard

If classes with the same names are used in the tests run by TestNG, then only the last result will be recorded.

Open gearup66 opened this issue 4 years ago • 2 comments

Describe the bug My project Selenide+TestNG+Allure+Maven I use TуstNG suites, which have test classes with the same names. The tests pass successfully, but the Allure report contains only a report on tests from the last TestSuite, for tests with the same class names.

To Reproduce There are two test suite

<test name = "correspondentTest1">
    <classes>
        <class name = "ru.ga.TestSaeLogin" />
        <class name = "ru.ga.TestScriptAddCorrespondent" />
        <class name = "ru.ga.TestScriptChangeCorrespondent" />
        <class name = "ru.ga.TestScriptDeleteCorrespondent" />
        <class name = "ru.ga.TestSaeLogout" />
    </classes>
</test>
<test name = "correspondentTest2">
    <classes>
        <class name = "ru.ga.TestSaeLogin1" />
        <class name = "ru.ga.TestScriptAddCorrespondent" />
        <class name = "ru.ga.TestScriptChangeCorrespondent" />
        <class name = "ru.ga.TestScriptDeleteCorrespondent" />
        <class name = "ru.ga.TestSaeLogout1" />
    </classes>
</test>

In maven pom.xml

                       <suiteXmlFiles>
                            <suiteXmlFile>src/test/java/ru/ga/TestsSuite1.xml</suiteXmlFile>
                               <suiteXmlFile>src/test/java/ru/ga/TestsSuite2.xml</suiteXmlFile>
                        </suiteXmlFiles>

start test maven command

mvn clean test

result in maven

[INFO] Results:

[INFO]

[INFO] Tests run: 16, Failures: 0, Errors: 0, Skipped: 0

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 02:22 min

[INFO] Finished at: 2021-08-19T06:47:46+03:00

[INFO] -------

Tests run: 16 that

        <class name = "ru.ga.TestScriptAddCorrespondent" /> - parametrized for 2 runs
        <class name = "ru.ga.TestScriptChangeCorrespondent" /> - parametrized for 2 runs
        <class name = "ru.ga.TestScriptDeleteCorrespondent" /> - parametrized for 2 runs

In Allure report

see Screenshots

Expected behavior test results with the same class names should not overwrite results

Screenshots image001 (2)

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

gearup66 avatar Aug 19 '21 04:08 gearup66

The results for other tests are probably put under Retries Tab if the test methods are same.

itkhanz avatar Dec 28 '22 23:12 itkhanz

This issue is reproducible only for Object Array DataProvider. For the Data Provider with ArrayList is generating individual Test nodes.

Issue for:

@Test(dataProvider = "dp", description = "tc1")
  public void tc1(Object[] td){
      System.out.println("pass");
  }
  @DataProvider(name = "dp")
  public Object[] dp() {
      Object[] arr = new Object[2];
      for (int i = 0; i < 2; i++)
          arr[i] = new Object[]{"chrome" , "Testing new " + i};
      return arr;
  }

Works fine for:

@Test(dataProvider = "dp1", description = "tc1")
  public void tc1(List<String> td){
      System.out.println("pass");
  }

  @DataProvider(name = "dp1")
  public Object[] dp1() {
      Object[] arr = new Object[2];
      for (int i = 0; i < 2; i++)
          arr[i] = Arrays.asList("chrome", "Testing new " + i);

      return arr;
  }

ghost avatar Jan 30 '23 14:01 ghost