Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit Eclipse - Display stack trace on success

I'm writing some unit tests in eclipse which expect exceptions to be thrown.

I wonder if there is an option to display the stack-trace when a test passes, it would be useful when you are writing test for the first time to check if the exception is been thrown really due to the case you are testing.

thanks!

like image 639
carrizo Avatar asked Oct 05 '22 04:10

carrizo


1 Answers

You shouldn't need to do that.

Use the @Test annotation with an expected argument:

@Test(expected=MyAppException.class)

If the test does not throw the exception it's a test failure.

There should be an Eclipse view option to show test logging output, but in general, explicit logging from tests isn't valuable. You can also debug your test if you don't trust the JUnit annotations.

like image 113
Dave Newton Avatar answered Oct 13 '22 12:10

Dave Newton