Listeners can't get any info about expectedExceptions?

12 views
Skip to first unread message

jweiss

unread,
Jun 26, 2009, 12:39:58 PM6/26/09
to testng-users
Hi,

I am starting to use the "expectedExceptions" annotation to test (for
instance) invalid input to my application.

The problem I'm having is that I want something printed to stdout that
when I expect an exception and didn't get one, I want to see what
exception was expected. I have an implementation of IResultListener,
ISuiteListener that can print the throwable when in fact the test
passes with the expected exception, but I can't handle the case where
the test fails. TestNG just prints that it expected an exception, but
doesn't say which one(s).

Cédric Beust ♔

unread,
Jun 26, 2009, 4:51:07 PM6/26/09
to testng...@googlegroups.com

Ah, it looks like the error message is okay when no exception is thrown:

Method test.tmp.A.f() should have thrown an exception of class java.lang.NumberFormatException

But when the wrong exception is thrown, it's not very verbose:

FAILED: f
java.lang.RuntimeException
    at test.tmp.A.f(A.java:37)

I agree that for the second case, the message should be "Expected NumberFormatException, but got RuntimeException".

Is this what you're asking?

--
Cédric


Cédric Beust ♔

unread,
Jun 26, 2009, 6:32:18 PM6/26/09
to testng...@googlegroups.com
Hi Jeffrey,

I just fixed this, can you try the beta and let me know?

http://testng.org/beta

--
Cedric


2009/6/26 Cédric Beust ♔ <cbe...@google.com>



--
Cédric


Reply all
Reply to author
Forward
0 new messages