TestNG Retry failing using DataProvider if i include ITestContext context in Test Method

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

TestNG Retry failing using DataProvider if i include ITestContext context in Test Method

bipo1980

Hello: is there another way to get the ITestContext in a test method? Or what am i doing wrong?


I included ITestContext as a parameter in the TestMethod but Retry fails. (TestNG Version > 6.9.10)


In the example below if i include ITestContext in the parameter then during the retry method Test1() is not called the second time.

BUT if i remove ITestContext from the method parameter then method Test1() is called the second time and result is as expected.


public class RetryProvider { @Test (dataProvider = "datasource") public void Test1(int code, String type, ITestContext context){ System.out.println("Test1(): " + code + " : " + type); Assert.fail(); //** enforce a retry **/ } @DataProvider(name = "datasource") public Object[][] getData(){ Object[][] data = new Object[1][2]; data[0][0] = 1; data[0][1] = "apple"; return data; } }



Result: if i exclude parameter "ITestContext context" in the test method
Test1(): 1 : apple This is from IRetryAnalyzer ::: Retrying test Test1 with status FAILURE for the 1 time(s). Test1(): 1 : apple [this is what is desired after retry]

Result: if i include parameter "ITestContext context" in the test method

 Test1(): 1 : apple This is from IRetryAnalyzer ::: Retrying test Test1 with status FAILURE for the 1 time(s). ::: note here that test method was not called the second time [WHY????]

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...