Amey Dhoke
unread,Dec 31, 2010, 9:33:27 AM12/31/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to testng-users
I am trying to test the specific exception message, but looks like
expectedExceptionsMessageRegExp doesn't work.
Here is the sample code and a test. This test should FAIL, but it is
passing -
public class SampleClass {
public void method() throws Exception {
throw new Exception("Incorrect Message");
}
}
public class SampleClassTest {
@Test(expectedExceptions = Exception.class,
expectedExceptionsMessageRegExp = "Sample Message")
public void shouldCheckForExpectedExceptionMessage() throws
Exception {
new SampleClass().method();
}
}
In the SampleClass.method(), I am throwing exception with message -
"Incorrect Message" and in the test, I am asserting that the expected
message is "Sample Message". But the test still passes.
I am using testng 5.11
Am I doing something wrong ? Or is this a bug ?