Skip to content

Commit 8225ead

Browse files
committed
add retry test
1 parent 16baf47 commit 8225ead

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

allure-testng/src/test/java/io/qameta/allure/test/FeatureCombinationsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>

0 commit comments

Comments
 (0)