Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TestNG reporter marks test as passed despite the test was not run by the IHookable. #201

Open
nsanghavi opened this Issue · 0 comments

1 participant

@nsanghavi

I have a custom listener which sets some global flag when any test fails:

public class MyListener extends TestListenerAdapter
{

@Override
public void onTestFailure(ITestResult tr)
{
super.onTestFailure(tr);

GlobalFlag.failureStatus = true;

}

Then, I have a MyHookable which checks if that flag is set. If set, just print to skip else call the method.

public class MyHookable implements IHookable
{

@Override
public void run(IHookCallBack icb, ITestResult testResult)
{
//if previous tests pased , allow next tests to run
if(GlobalFlag.failureStatus == false)
{

  icb.runTestMethod(testResult);
}

//don't allow any more tests to run
else
{
System.out.println("Skipping test execution for "+testResult.getTestName());

}

}

}

I created 3 tests(Test1, Test2, Test3) and I made all the tests to fail with
Assert.assertEquals(true, false);

when I am executing these tests, I see that it's always coming in else block after executing Test1 and printing that test2 and test3 is getting skipped but, in the result at the end , it says
Test1 Failed
Test2 Passed(despite Assertion failure)
Test3 Passed. (despite Assertion failure)

It looks like reporter doesn't know if the test being skipped by IHookable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.