File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ package io .qameta .allure .samples ;
2+
3+ import org .testng .ITestResult ;
4+ import org .testng .annotations .Test ;
5+ import org .testng .util .RetryAnalyzerCount ;
6+
7+ /**
8+ * @author charlie (Dmitry Baev).
9+ */
10+ public class RetryTest {
11+
12+ @ Test (retryAnalyzer = Retry .class )
13+ public void testWithRetry () throws Exception {
14+ throw new RuntimeException ("Unexpected failure" );
15+ }
16+
17+ public static class Retry extends RetryAnalyzerCount {
18+
19+ @ Override
20+ public boolean retryMethod (ITestResult result ) {
21+ boolean willRetry = !result .isSuccess ();
22+ if (willRetry ) {
23+ result .setAttribute ("retry" , true );
24+ }
25+ return willRetry ;
26+ }
27+ }
28+ }
Original file line number Diff line number Diff line change @@ -400,6 +400,14 @@ public void bddAnnotationsTest() throws Exception {
400400 );
401401 }
402402
403+ @ Test
404+ public void retryTest () throws Exception {
405+ runTestNgSuites ("suites/retry.xml" );
406+ List <TestResult > testResults = results .getTestResults ();
407+ assertThat (testResults )
408+ .hasSize (2 );
409+ }
410+
403411 private Predicate <TestResult > hasLinks () {
404412 return testResult -> !testResult .getLinks ().isEmpty ();
405413 }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
3+
4+ <suite name =" Retry suite" >
5+ <test name =" Retry tests" >
6+ <classes >
7+ <class name =" io.qameta.allure.samples.RetryTest" />
8+ </classes >
9+ </test >
10+ </suite >
You can’t perform that action at this time.
0 commit comments