-1

Is there a useful JUnit view in Eclipse, where I can see the errors right away, e.g. also print the stack trace to the console?

Currently I end up copying the stack trace from Eclipse to a text editor in order to see the assertion error, e.g. in this case

enter image description here

It's impossible to the the actual error message at first glance:

org.springframework.expression.ParseException: Expression '#{vertragsnummer!=null?<vertragsnummer>#{vertragsnummer}</vertragsnummer>:''' @ 0: No ending suffix '}' for expression starting at character 0: #{vertragsnummer!=null?<vertragsnummer>#{vertragsnummer}</vertragsnummer>:''
Stefan K.
  • 7,701
  • 6
  • 52
  • 64
  • Can you elaborate what it is you're missing that the JUnit view doesn't provide? I see the exception class and message (except the part your screen capture chopped off), the full stack, which test produced the exception. What more are you looking for? – E-Riz Mar 03 '16 at 18:36
  • it's the end of the screen. The actual reason for the error is not wrapped and thus not readable, even if the junit view covers half of my screen. – Stefan K. Mar 03 '16 at 19:57
  • That view scrolls horizontally, right? Also, you can hover over the error line and a tooltip will show the entire exception message. Sounds like what you want is wrapping of that view's contents, instead of scrolling. – E-Riz Mar 03 '16 at 20:01
  • 1
    It's a bit intrusive, but see http://stackoverflow.com/q/7503277/639520 and the accepted answer for a general solution to logging ALL exceptions that result from tests. – E-Riz Mar 03 '16 at 20:05
  • thanks. I was hoping it's somehow possible to print the failed, uncatched exception to the console :( – Stefan K. Mar 03 '16 at 20:23
  • 1
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=488981 :-) – E-Riz Mar 03 '16 at 20:44

1 Answers1

1

I'm not sure exactly what you're trying to achieve, but the error in your screen shot is not an assertion failure, it's an exception thrown from some code that your test is (indirectly) calling. So there is no "assertion error" to view.

Having said that, you can double-click on the exception in the JUnit view and Eclipse will take you to the point in code where that exception occurred. In fact, you can do that on any level in the stack in the JUnit view. Note that if you don't have the source code for the code that has thrown an exception, you won't get a useful view of that code (obviously); that's a different question entirely.

If you're having trouble reading long exception messages in the JUnit view, you can move and resize it to fit your needs. For example, I usually keep it along the left edge of the window, in a group by itself which I minimize and then restore as needed; that way I can stretch it out horizontally as much as needed for long messages.

E-Riz
  • 31,431
  • 9
  • 97
  • 134
  • true, it's not an assertion error (updated my question). – Stefan K. Mar 03 '16 at 15:23
  • still, I would be much more useful to see the exception on the console than in this clumsy junit view. – Stefan K. Mar 03 '16 at 15:23
  • 1
    @StefanK., did you open the Console view in Eclipse? If you really just want a plain text log of exceptions, that's where you'll find it (assuming the exception was logged by whatever code threw it). I prefer the richness that the JUnit view gives, it's actually interactive and much better for assertion failures. – E-Riz Mar 03 '16 at 15:25