forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien Herr
committed
Nov 5, 2015
1 parent
2c12573
commit 789b22b
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/java/test/retryAnalyzer/github857/GitHub857Listener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package test.retryAnalyzer.github857; | ||
|
||
import org.testng.ITestContext; | ||
import org.testng.ITestResult; | ||
import org.testng.TestListenerAdapter; | ||
import org.testng.collections.Lists; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class GitHub857Listener extends TestListenerAdapter { | ||
|
||
public static List<ITestResult> | ||
passedTests = | ||
Collections.synchronizedList(Lists.<ITestResult>newArrayList()); | ||
public static List<ITestResult> | ||
failedTests = | ||
Collections.synchronizedList(Lists.<ITestResult>newArrayList()); | ||
public static List<ITestResult> | ||
skippedTests = | ||
Collections.synchronizedList(Lists.<ITestResult>newArrayList()); | ||
public static List<ITestResult> | ||
failedButWSPerTests = | ||
Collections.synchronizedList(Lists.<ITestResult>newArrayList()); | ||
|
||
@Override | ||
public void onTestSuccess(ITestResult result) { | ||
passedTests.add(result); | ||
} | ||
|
||
@Override | ||
public void onTestFailure(ITestResult result) { | ||
failedTests.add(result); | ||
} | ||
|
||
@Override | ||
public void onTestSkipped(ITestResult result) { | ||
skippedTests.add(result); | ||
} | ||
|
||
@Override | ||
public void onTestFailedButWithinSuccessPercentage(ITestResult result) { | ||
failedButWSPerTests.add(result); | ||
} | ||
|
||
@Override | ||
public void onTestStart(ITestResult result) {} | ||
|
||
@Override | ||
public void onStart(ITestContext context) {} | ||
|
||
@Override | ||
public void onFinish(ITestContext context) {} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/java/test/retryAnalyzer/github857/GitHub857Retry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package test.retryAnalyzer.github857; | ||
|
||
import org.testng.IRetryAnalyzer; | ||
import org.testng.ITestResult; | ||
|
||
public class GitHub857Retry implements IRetryAnalyzer { | ||
|
||
private static final int MAX_RETRY_COUNT_PER_TEST = 1; | ||
private int retryCountPerTest = 0; | ||
|
||
@Override | ||
public boolean retry(ITestResult result) { | ||
if (retryCountPerTest < MAX_RETRY_COUNT_PER_TEST) { | ||
retryCountPerTest++; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/java/test/retryAnalyzer/github857/GitHub857Sample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package test.retryAnalyzer.github857; | ||
|
||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.fail; | ||
|
||
@Listeners(GitHub857Listener.class) | ||
public class GitHub857Sample { | ||
|
||
@Test(retryAnalyzer = GitHub857Retry.class) | ||
public void test() { | ||
fail("Failing"); | ||
} | ||
} |