-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline data providers & retrial of failed tests
Closes #2884 When a data driven test fails, then ensure that we don’t call the data provider once again when retrying the test (we seem to invoke the data provider multiple times, but ignore the value) As part of fixing this, getting rid of the test for #2157. #2157 - deals with null pointer exceptions arising Out of data provider that was re-invoked as a result Of us retrying a failed test. But now since a data provider is NOT going to be re-invoked the changes for #2157 become irrelevant.
- Loading branch information
1 parent
5834b19
commit ebd9dae
Showing
7 changed files
with
64 additions
and
85 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
7 changes: 6 additions & 1 deletion
7
testng-core/src/main/java/org/testng/DataProviderInvocationException.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
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
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
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
49 changes: 0 additions & 49 deletions
49
.../test/java/test/dataprovider/issue2157/TestClassWithDataProviderThatThrowsExceptions.java
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
testng-core/src/test/java/test/dataprovider/issue2884/TestClassSample.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,48 @@ | ||
package test.dataprovider.issue2884; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
import org.testng.Assert; | ||
import org.testng.IRetryAnalyzer; | ||
import org.testng.ITestResult; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
public class TestClassSample { | ||
|
||
public static final AtomicInteger dataProviderInvocationCount = new AtomicInteger(0); | ||
|
||
@Test(dataProvider = "dp", retryAnalyzer = TryAgain.class) | ||
public void testMethod(Pojo user) { | ||
Assert.fail(); | ||
} | ||
|
||
@DataProvider(name = "dp") | ||
public static Object[][] getTestData() { | ||
dataProviderInvocationCount.incrementAndGet(); | ||
return new Object[][] {{new Pojo().setName("John")}}; | ||
} | ||
|
||
public static class TryAgain implements IRetryAnalyzer { | ||
|
||
private int counter = 1; | ||
|
||
@Override | ||
public boolean retry(ITestResult result) { | ||
return counter++ != 3; | ||
} | ||
} | ||
|
||
public static class Pojo { | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Pojo setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
} | ||
} |