java - Mark TestNG test as passed - Stack Overflow
You can write your own listener that will do this for you. I have written some thing that works(I dont know if this what you are exactly looking for).
My Listener :
public class MyResultListener implements ISuiteListener{ @Override public void onStart(ISuite suite) { // TODO Auto-generated method stub } @Override public void onFinish(ISuite suite) { Map<String,ISuiteResult> resultMap = suite.getResults(); for(Map.Entry<String, ISuiteResult> ent :resultMap.entrySet()) { ISuiteResult res = ent.getValue(); IResultMap failedTestMap = res.getTestContext().getFailedTests(); IResultMap passTestMap = res.getTestContext().getPassedTests(); for(ITestResult testResult :failedTestMap.getAllResults()){ if(testResult.getThrowable().getClass().equals(new MyOwnException())){} System.out.println("My Own exception thrown"); failedTestMap.removeResult(testResult); passTestMap.addResult(testResult, testResult.getMethod()); } } } }
This listener will be run after suite (It is just what i ahve done, You can implement other listeners also to get what you exactly need. This is just my version). Here, I will get the failed tests and see if the failed tests throw my custom exception. In that case I will remove that result from failed tests and add it to passed set.
Read full article from java - Mark TestNG test as passed - Stack Overflow
No comments:
Post a Comment