shankar KC
2016-01-07 11:57:35 UTC
Hi all,
I have a class file as below.
public class FailingTest {
private Logger logger = Logger.getLogger(getClass());
static int reRunFlag = 0;
@BeforeClass
public void initValues()
{
reRunFlag = 0;
}
@Test()
public void failingTestCase() {
logger.info( "failing Test Case called " + (++reRunFlag) + " times");
if(reRunFlag ==1)
{
assertTrue(false);
}
}
@Test(dependsOnMethods = "failingTestCase")
public void validateRerunOfFailedTest() {
assertTrue(( reRunFlag > 1) ,
String.format("tests expected to be rerurun. So expecting >1 as
invocation count. but found %d. ",
reRunFlag));
}
}
I have implemented retry analyzer. Test (failingTestCase) runs 2nd time and
passes. But strangly testng skips the 2nd dependent test. I noticed this
method of Invoker class gives flag saying haveBeenRunSuccessfully false.
private boolean haveBeenRunSuccessfully(ITestNGMethod testMethod,
ITestNGMethod[] methods) {
// Make sure the method has been run successfully
for (ITestNGMethod method : methods) {
Set<ITestResult> results = keepSameInstances(testMethod, m_notifier
.getPassedTests(method));
Set<ITestResult> failedAndSkippedMethods = Sets.newHashSet();
failedAndSkippedMethods.addAll(m_notifier.getFailedTests(method));
failedAndSkippedMethods.addAll(m_notifier.getSkippedTests(method));
Set<ITestResult> failedresults = keepSameInstances(testMethod,
failedAndSkippedMethods);
// If failed results were returned on the same instance, then these
tests didn't pass
if (failedresults != null && failedresults.size() > 0) {
return false;
}
for (ITestResult result : results) {
if(!result.isSuccess()) {
return false;
}
}
}
return true;
}
Cedric can you please take a look and fix if this is a defect?
I have a class file as below.
public class FailingTest {
private Logger logger = Logger.getLogger(getClass());
static int reRunFlag = 0;
@BeforeClass
public void initValues()
{
reRunFlag = 0;
}
@Test()
public void failingTestCase() {
logger.info( "failing Test Case called " + (++reRunFlag) + " times");
if(reRunFlag ==1)
{
assertTrue(false);
}
}
@Test(dependsOnMethods = "failingTestCase")
public void validateRerunOfFailedTest() {
assertTrue(( reRunFlag > 1) ,
String.format("tests expected to be rerurun. So expecting >1 as
invocation count. but found %d. ",
reRunFlag));
}
}
I have implemented retry analyzer. Test (failingTestCase) runs 2nd time and
passes. But strangly testng skips the 2nd dependent test. I noticed this
method of Invoker class gives flag saying haveBeenRunSuccessfully false.
private boolean haveBeenRunSuccessfully(ITestNGMethod testMethod,
ITestNGMethod[] methods) {
// Make sure the method has been run successfully
for (ITestNGMethod method : methods) {
Set<ITestResult> results = keepSameInstances(testMethod, m_notifier
.getPassedTests(method));
Set<ITestResult> failedAndSkippedMethods = Sets.newHashSet();
failedAndSkippedMethods.addAll(m_notifier.getFailedTests(method));
failedAndSkippedMethods.addAll(m_notifier.getSkippedTests(method));
Set<ITestResult> failedresults = keepSameInstances(testMethod,
failedAndSkippedMethods);
// If failed results were returned on the same instance, then these
tests didn't pass
if (failedresults != null && failedresults.size() > 0) {
return false;
}
for (ITestResult result : results) {
if(!result.isSuccess()) {
return false;
}
}
}
return true;
}
Cedric can you please take a look and fix if this is a defect?
--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.