cbeust/testng — Issue #170: SkipException should not fail a test annotated with expectedExceptions
Author: fmisiak
Created: 2012-02-17 16:47:32+00:00
State: open

see discussion at http://groups.google.com/group/testng-users/browse_thread/thread/72a5a20c9d49e44

A test method annotated with "expectedExceptions" should not fail when the test method (or listener) throws a SkipException.

Example:

package com.com.test2;

import org.testng.SkipException;
import org.testng.annotations.Test;

public class NewTest2 {

@Test(expectedExceptions=NullPointerException.class)
public void a2() {
// throw new NullPointerException();
throw new SkipException("test");
}
}

Console output:

FAILED: a2
org.testng.TestException:
Expected exception java.lang.NullPointerException but got org.testng.TestException:
Expected exception java.lang.NullPointerException but got org.testng.SkipException: test
at org.testng.internal.Invoker.handleInvocationResults(Invoker.java:1459)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1222)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:758)
at org.testng.TestRunner.run(TestRunner.java:613)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1141)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1066)
at org.testng.TestNG.run(TestNG.java:978)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
Caused by: org.testng.TestException:
....