3838import io .qameta .allure .test .AllureResultsWriterStub ;
3939import io .qameta .allure .testfilter .TestPlan ;
4040import io .qameta .allure .testfilter .TestPlanV1_0 ;
41+ import io .qameta .allure .testng .samples .PriorityTests ;
4142import io .qameta .allure .testng .samples .TestsWithIdForFilter ;
4243import org .assertj .core .api .Condition ;
4344import org .assertj .core .groups .Tuple ;
5051import java .net .URL ;
5152import java .util .Arrays ;
5253import java .util .Collection ;
54+ import java .util .Comparator ;
5355import java .util .List ;
5456import java .util .Objects ;
5557import java .util .Optional ;
@@ -434,11 +436,20 @@ public void skippedSuiteTest() {
434436 List <TestResultContainer > testContainers = results .getTestResultContainers ();
435437 assertThat (testResults )
436438 .extracting (TestResult ::getName , TestResult ::getStatus )
437- .contains (
439+ .containsExactlyInAnyOrder (
438440 tuple ("skippedTest" , Status .SKIPPED ),
441+ tuple ("skipSuite" , Status .BROKEN ),
439442 tuple ("testWithOneStep" , Status .SKIPPED )
440443 );
441- assertThat (testContainers ).as ("Unexpected quantity of testng containers has been written" ).hasSize (4 );
444+ assertThat (testContainers )
445+ .as ("Unexpected quantity of testng containers has been written" )
446+ .extracting (TestResultContainer ::getName )
447+ .containsExactlyInAnyOrder (
448+ "Test tag 8" ,
449+ "Test suite 8" ,
450+ "io.qameta.allure.testng.samples.SkippedSuite" ,
451+ "io.qameta.allure.testng.samples.TestsWithSteps"
452+ );
442453
443454 assertThat (findTestContainerByName (results , "Test suite 8" ).getBefores ())
444455 .as ("Before suite container should have a before method with one step" )
@@ -677,7 +688,7 @@ public void ownerTest() {
677688 .filter (label -> "owner" .equals (label .getName ()))
678689 .map (Label ::getValue )
679690 .sorted ()
680- .collect (Collectors .joining ("," ,"[" ,"]" ))
691+ .collect (Collectors .joining ("," , "[" , "]" ))
681692 )
682693 .containsExactlyInAnyOrder (
683694 tuple ("io.qameta.allure.testng.samples.OwnerMethodTest.testWithOwner" , "[charlie]" ),
@@ -1141,8 +1152,6 @@ public Object[][] failedFixtures() {
11411152 @ Test (dataProvider = "failedFixtures" )
11421153 @ AllureFeatures .Fixtures
11431154 public void shouldAddBeforeFixtureToFakeTestResult (final String suite , final String fixture ) {
1144- System .out .println (suite );
1145- System .out .println (fixture );
11461155 final AllureResults results = runTestNgSuites (suite );
11471156 final Optional <TestResult > result = results .getTestResults ().stream ()
11481157 .filter (r -> r .getName ().contains (fixture ))
@@ -1156,6 +1165,19 @@ public void shouldAddBeforeFixtureToFakeTestResult(final String suite, final Str
11561165 .contains (result .get ().getUuid ());
11571166 }
11581167
1168+ @ Test
1169+ @ AllureFeatures .Ordering
1170+ public void shouldOrderTests () {
1171+ final AllureResults results = runTestPlan (null , PriorityTests .class );
1172+ final List <String > ordered = results .getTestResults ().stream ()
1173+ .sorted (Comparator .comparing (this ::getOrderParameter ))
1174+ .map (TestResult ::getName )
1175+ .collect (Collectors .toList ());
1176+ System .out .println (Arrays .toString (ordered .toArray ()));
1177+ assertThat (ordered )
1178+ .containsExactly ("zTest" , "yTest" , "xTest" , "wTest" , "vTest" , "vTest" );
1179+ }
1180+
11591181 @ Step ("Run testng suites {suites}" )
11601182 private AllureResults runTestNgSuites (final Consumer <TestNG > configurer ,
11611183 final String ... suites ) {
@@ -1338,7 +1360,7 @@ private static void checkTestJavadocDescriptions(List<TestResult> results, Strin
13381360
13391361 @ Test
13401362 @ AllureFeatures .Filtration
1341- public void simpleFiltration () {
1363+ public void simpleFiltration () {
13421364 TestPlanV1_0 plan = new TestPlanV1_0 ().setTests (Arrays .asList (test1 , test2 , test3 ));
13431365 List <TestResult > testResults = runTestPlan (plan , TestsWithIdForFilter .class ).getTestResults ();
13441366
@@ -1354,7 +1376,7 @@ public void simpleFiltration() {
13541376
13551377 @ Test
13561378 @ AllureFeatures .Filtration
1357- public void onlyId () {
1379+ public void onlyId () {
13581380 TestPlanV1_0 plan = new TestPlanV1_0 ().setTests (Arrays .asList (onlyId2 , onlyId4 ));
13591381 List <TestResult > testResults = runTestPlan (plan , TestsWithIdForFilter .class ).getTestResults ();
13601382
@@ -1397,7 +1419,7 @@ public void skippedTest() {
13971419
13981420 @ Test
13991421 @ AllureFeatures .Filtration
1400- public void correctIdIncorrectSelector () {
1422+ public void correctIdIncorrectSelector () {
14011423 TestPlanV1_0 plan = new TestPlanV1_0 ().setTests (
14021424 Arrays .asList (test1 , test2 , correctIdIncorrectSelector , correctIdIncorrectSelectorFailed )
14031425 );
@@ -1413,7 +1435,7 @@ public void correctIdIncorrectSelector() {
14131435 );
14141436 }
14151437
1416- public AllureResultsWriterStub runTestPlan (TestPlan plan , final Class <?> ... testClasses ) {
1438+ public AllureResultsWriterStub runTestPlan (TestPlan plan , final Class <?>... testClasses ) {
14171439 final AllureResultsWriterStub results = new AllureResultsWriterStub ();
14181440 final AllureLifecycle lifecycle = new AllureLifecycle (results );
14191441 final AllureTestNg adapter = new AllureTestNg (lifecycle , new AllureTestNgTestFilter (plan ));
@@ -1437,4 +1459,13 @@ public AllureResultsWriterStub runTestPlan(TestPlan plan, final Class<?> ... tes
14371459 }
14381460 }
14391461
1462+ private Integer getOrderParameter (final TestResult result ) {
1463+ return result .getParameters ().stream ()
1464+ .filter (p -> p .getName ().equals ("order" ))
1465+ .map (Parameter ::getValue )
1466+ .map (Integer ::parseInt )
1467+ .findAny ()
1468+ .orElse (0 );
1469+ }
1470+
14401471}
0 commit comments