JUnit Eclipse - track stack trace

I am writing some unit tests in eclipse that expect exceptions to be thrown.

I wonder if it is possible to display the stack trace when passing the test, it would be useful when you are testing the test for the first time to check if the exception is really caused by the case you are testing.

thank!

+5
source share
2 answers

You do not need to do this.

Use annotation @Testwith argument expected:

@Test(expected=MyAppException.class)

If the test does not throw an exception, this is a test error.

Eclipse , . , JUnit.

+3

System.out.print() catch ? , , , , , , .

log4j log.debug()?

+1

All Articles