views:

108

answers:

3

Hi, I'm not much of an Eclipse guru, so please forgive my clumsiness.

In Eclipse, when I call Assert.assertEquals(obj1,obj2) and that fails, how do I get the IDE to show me obj1 and obj2?

I'm using JExample, but I guess that shouldn't make a difference.


Edit: Here's what I see:
.

+2  A: 

Assert.assertEquals() will put the toString() representation of the expected and actual object in the message of the AssertionFailedError it throws, and eclipse will display that in the "failure trace" part of the JUnit view:

alt text

If you have complex objects you want to inspect, you'll have to use the debugger and put a breakpoint inside Assert.assertEquals()

Michael Borgwardt
+1  A: 

What are you seeing?

When you do assertTrue() and it fails, you see a null.

But when you do assertEquals, it is supposed to show you what it expected and what it actually got.

If you are using JUnit, mke sure you are looking at the JUnit view and moving the mouse to the failed test.

Uri
+1  A: 

If the information in the JUnit view is not enough for you, you can always set a exception breakpoint on, for example, java.lang.AssertionError. When running the test, the debugger will stop immediately before the exception is actually being thrown.

JesperE
Yup, I guess that'll do it. Although back when I used TestNG, I kind of enjoyed the column-view: expected left, actual on the right.
nes1983