3939import io .qameta .allure .testng .samples .TestsWithIdForFilter ;
4040import org .assertj .core .api .Condition ;
4141import org .assertj .core .groups .Tuple ;
42- import org .testng .ITestNGListener ;
4342import org .testng .TestNG ;
4443import org .testng .annotations .DataProvider ;
4544import org .testng .annotations .Test ;
@@ -130,7 +129,7 @@ public void shouldNotDisplayConfigurationFailsAsTests() {
130129 public void shouldSetConfigurationProperty () {
131130 AllureTestNgConfig allureTestNgConfig = AllureTestNgConfig .loadConfigProperties ();
132131 allureTestNgConfig .setHideDisabledTests (true );
133- assertThat (allureTestNgConfig .isHideDisabledTests ()).isEqualTo ( true );
132+ assertThat (allureTestNgConfig .isHideDisabledTests ()).isTrue ( );
134133 }
135134
136135 @ AllureFeatures .Parallel
@@ -507,7 +506,7 @@ public void multipleSuites() {
507506 .hasSize (3 );
508507 List <String > uids = testResults .stream ().map (TestResult ::getUuid ).collect (Collectors .toList ());
509508 assertThat (testContainers ).as ("Unexpected quantity of testng containers has been written" )
510- .hasSize (8 ).extracting (TestResultContainer ::getName )
509+ .hasSize (9 ).extracting (TestResultContainer ::getName )
511510 .contains (beforeMethodName , beforeMethodName , firstTagName , firstSuiteName , secondTagName ,
512511 secondSuiteName );
513512
@@ -553,7 +552,7 @@ public void parallelMethods() {
553552 assertThat (testResults ).as ("Unexpected quantity of testng case results has been written" )
554553 .hasSize (2001 );
555554 assertThat (testContainers ).as ("Unexpected quantity of testng containers has been written" )
556- .hasSize (6006 );
555+ .hasSize (6007 );
557556
558557 assertContainersPerMethod (before1 , testContainers , uids );
559558 assertContainersPerMethod (before2 , testContainers , uids );
@@ -1218,7 +1217,7 @@ public void shouldAddBeforeFixtureToFakeTestResult(final String suite, final Str
12181217 .findAny ();
12191218 assertThat (result ).as ("Before failed fake test result" ).isNotEmpty ();
12201219 final Optional <TestResultContainer > befores = results .getTestResultContainers ().stream ()
1221- .filter (c -> Objects .nonNull (c .getBefores ()) && c .getBefores ().size () > 0 )
1220+ .filter (c -> Objects .nonNull (c .getBefores ()) && ! c .getBefores ().isEmpty () )
12221221 .findAny ();
12231222 assertThat (result ).as ("Before failed configuration container" ).isNotEmpty ();
12241223 assertThat (befores .get ().getChildren ())
@@ -1252,7 +1251,6 @@ private AllureResults runTestNgSuites(AllureTestNgConfig config, final String...
12521251
12531252 private AllureResults runTestNgSuites (final Consumer <TestNG > configurer ,
12541253 final String ... suites ) {
1255- ;
12561254 return runTestNgSuites (configurer , AllureTestNgConfig .loadConfigProperties (), suites );
12571255 }
12581256
@@ -1276,7 +1274,7 @@ private AllureResults runTestNgSuites(final Consumer<TestNG> configurer,
12761274 new AllureTestNgTestFilter (),
12771275 config );
12781276 final TestNG testNg = new TestNG (false );
1279- testNg .addListener (( ITestNGListener ) adapter );
1277+ testNg .addListener (adapter );
12801278 testNg .setTestSuites (suiteFiles );
12811279
12821280 configurer .accept (testNg );
@@ -1461,7 +1459,7 @@ public void onlyId() {
14611459 @ Test
14621460 @ AllureFeatures .Filtration
14631461 public void idAssignToOtherTest () {
1464- TestPlanV1_0 plan = new TestPlanV1_0 ().setTests (Arrays . asList (otherId ));
1462+ TestPlanV1_0 plan = new TestPlanV1_0 ().setTests (singletonList (otherId ));
14651463 List <TestResult > testResults = runTestPlan (plan , TestsWithIdForFilter .class ).getTestResults ();
14661464
14671465 assertThat (testResults )
@@ -1476,7 +1474,7 @@ public void idAssignToOtherTest() {
14761474 @ Test
14771475 @ AllureFeatures .Filtration
14781476 public void skippedTest () {
1479- TestPlanV1_0 plan = new TestPlanV1_0 ().setTests (Arrays . asList (skipped ));
1477+ TestPlanV1_0 plan = new TestPlanV1_0 ().setTests (singletonList (skipped ));
14801478 List <TestResult > testResults = runTestPlan (plan , TestsWithIdForFilter .class ).getTestResults ();
14811479 assertThat (testResults )
14821480 .hasSize (1 )
@@ -1508,13 +1506,140 @@ public AllureResults runTestPlan(final TestPlan plan, final Class<?>... testClas
15081506 return RunUtils .runTests (lifecycle -> {
15091507 final AllureTestNg adapter = new AllureTestNg (lifecycle , new AllureTestNgTestFilter (plan ));
15101508 final TestNG testNG = new TestNG (false );
1511- testNG .addListener (( ITestNGListener ) adapter );
1509+ testNG .addListener (adapter );
15121510 testNG .setTestClasses (testClasses );
15131511 testNG .setOutputDirectory ("build/test-output" );
15141512 testNG .run ();
15151513 });
15161514 }
15171515
1516+ @ AllureFeatures .Fixtures
1517+ @ Test (description = "Should process data provider in setup" )
1518+ public void shouldProcessDataProviderInSetup () {
1519+ final AllureResults results = runTestNgSuites ("suites/data-provider-with-attachment.xml" );
1520+
1521+ assertThat (results .getTestResultContainers ())
1522+ .flatExtracting (TestResultContainer ::getBefores )
1523+ .extracting (FixtureResult ::getName , FixtureResult ::getStatus )
1524+ .contains (Tuple .tuple ("dataProvider" , Status .PASSED ));
1525+
1526+ assertThat (results .getTestResultContainers ())
1527+ .flatExtracting (TestResultContainer ::getBefores )
1528+ .filteredOn ("name" , "dataProvider" )
1529+ .flatExtracting (FixtureResult ::getAttachments )
1530+ .hasSize (1 )
1531+ .extracting (Attachment ::getName )
1532+ .contains ("attachment" );
1533+ }
1534+
1535+ @ AllureFeatures .Fixtures
1536+ @ Test (description = "Should process failed data provider in setup" )
1537+ public void shouldProcessFailedDataProviderInSetup () {
1538+ final AllureResults results = runTestNgSuites ("suites/failed-data-provider.xml" );
1539+
1540+ assertThat (results .getTestResultContainers ())
1541+ .flatExtracting (TestResultContainer ::getBefores )
1542+ .extracting (FixtureResult ::getName , FixtureResult ::getStatus )
1543+ .contains (Tuple .tuple ("dataProvider" , Status .BROKEN ));
1544+ }
1545+
1546+ @ AllureFeatures .Fixtures
1547+ @ Test (description = "Should process flaky data provider in setup" )
1548+ public void shouldProcessFlakyDataProvider () {
1549+ final AllureResults results = runTestNgSuites ("suites/flaky-data-provider.xml" );
1550+
1551+ assertThat (results .getTestResultContainers ())
1552+ .flatExtracting (TestResultContainer ::getBefores )
1553+ .extracting (FixtureResult ::getName , FixtureResult ::getStatus )
1554+ .containsSubsequence (
1555+ Tuple .tuple ("provide" , Status .BROKEN ),
1556+ Tuple .tuple ("provide" , Status .PASSED )
1557+ );
1558+ }
1559+
1560+ @ AllureFeatures .Fixtures
1561+ @ Test (description = "Should properly link data provider container to test result" )
1562+ public void shouldProperlyLinkDataProviderContainerToTestResult () {
1563+ final AllureResults results = runTestNgSuites ("suites/data-provider-with-attachment.xml" );
1564+
1565+ final TestResult tr = findTestResultByName (results , "test" );
1566+ final TestResultContainer dpContainer = results .getTestResultContainers ().stream ()
1567+ .filter (c -> c .getName ().equals ("test" ))
1568+ .findFirst ()
1569+ .orElseThrow (() -> new IllegalStateException ("DP container not found" ));
1570+
1571+ assertThat (dpContainer .getChildren ())
1572+ .contains (tr .getUuid ());
1573+ }
1574+
1575+ @ AllureFeatures .Fixtures
1576+ @ Test (description = "Should link multiple tests to data provider container" )
1577+ public void shouldLinkMultipleTestsToDataProviderContainer () {
1578+ final AllureResults results = runTestNgSuites ("suites/data-provider-multiple-tests.xml" );
1579+
1580+ final List <TestResult > test1Results = results .getTestResults ().stream ()
1581+ .filter (tr -> tr .getName ().equals ("test1" ))
1582+ .collect (Collectors .toList ());
1583+ final List <TestResult > test2Results = results .getTestResults ().stream ()
1584+ .filter (tr -> tr .getName ().equals ("test2" ))
1585+ .collect (Collectors .toList ());
1586+
1587+ assertThat (test1Results ).hasSize (2 );
1588+ assertThat (test2Results ).hasSize (2 );
1589+
1590+ final TestResultContainer dpContainer1 = findTestContainerByName (results , "test1" );
1591+ final TestResultContainer dpContainer2 = findTestContainerByName (results , "test2" );
1592+
1593+ assertThat (dpContainer1 .getChildren ())
1594+ .containsAll (test1Results .stream ().map (TestResult ::getUuid ).collect (Collectors .toList ()));
1595+ assertThat (dpContainer2 .getChildren ())
1596+ .containsAll (test2Results .stream ().map (TestResult ::getUuid ).collect (Collectors .toList ()));
1597+ }
1598+
1599+ @ AllureFeatures .Fixtures
1600+ @ Test (description = "Should link inherited data provider" )
1601+ public void shouldLinkInheritedDataProvider () {
1602+ final AllureResults results = runTestNgSuites ("suites/data-provider-inheritance.xml" );
1603+
1604+ final TestResult testBase = findTestResultByName (results , "testBase" );
1605+ final TestResult testChild = findTestResultByName (results , "testChild" );
1606+
1607+ final TestResultContainer dpContainerBase = findTestContainerByName (results , "testBase" );
1608+ final TestResultContainer dpContainerChild = findTestContainerByName (results , "testChild" );
1609+
1610+ assertThat (dpContainerBase .getChildren ()).contains (testBase .getUuid ());
1611+ assertThat (dpContainerChild .getChildren ()).contains (testChild .getUuid ());
1612+ }
1613+
1614+ @ AllureFeatures .Fixtures
1615+ @ Test (description = "Should link correct data provider in multiple classes" )
1616+ public void shouldLinkCorrectDataProviderInMultipleClasses () {
1617+ final AllureResults results = runTestNgSuites ("suites/data-provider-multiple-classes.xml" );
1618+
1619+ final TestResult test1 = findTestResultByName (results , "test1" );
1620+ final TestResult test2 = findTestResultByName (results , "test2" );
1621+
1622+ final TestResultContainer dpContainer1 = findTestContainerByName (results , "test1" );
1623+ final TestResultContainer dpContainer2 = findTestContainerByName (results , "test2" );
1624+
1625+ assertThat (dpContainer1 .getChildren ())
1626+ .contains (test1 .getUuid ())
1627+ .doesNotContain (test2 .getUuid ());
1628+ assertThat (dpContainer2 .getChildren ())
1629+ .contains (test2 .getUuid ())
1630+ .doesNotContain (test1 .getUuid ());
1631+ }
1632+
1633+ @ AllureFeatures .Fixtures
1634+ @ Test (description = "Should process parallel data provider" )
1635+ public void shouldProcessParallelDataProvider () {
1636+ final AllureResults results = runTestNgSuites ("suites/data-provider-parallel.xml" );
1637+
1638+ assertThat (results .getTestResults ()).hasSize (4 );
1639+ final TestResultContainer dpContainer = findTestContainerByName (results , "test" );
1640+ assertThat (dpContainer .getChildren ()).hasSize (4 );
1641+ }
1642+
15181643 private Integer getOrderParameter (final TestResult result ) {
15191644 return result .getParameters ().stream ()
15201645 .filter (p -> p .getName ().equals ("order" ))
0 commit comments