expectedExceptionsMessageRegExp Not working

301 views
Skip to first unread message

Amey Dhoke

unread,
Dec 31, 2010, 9:33:27 AM12/31/10
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 ?

Cédric Beust ♔

unread,
Dec 31, 2010, 10:18:45 AM12/31/10
to testng...@googlegroups.com
Can you try with the latest version?

-- 
Cédric



--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric


Reply all
Reply to author
Forward
0 new messages