0
I have a Junit test case to test a single class. The class to be tested contains only one "sum" method that sums two numbers. To test if it is correct, I use the following method: Assert.assertEquals(2, meu_objeto.sum(1, 2));
The result appears in a Junit tab in the eclipse, in a part called Failure Trace. The message says: junit.framework.AssertionFailedError: expected:<2> but was:<3>
You can take this message and place it inside a String variable?
tries to capture with Try/catch
– mau humor
I’ve tried, @user5978. I can’t get any results from this.
– Araújo Filho
http://junit.sourceforge.net/junit3.8.1/javadoc/junit/framework/AssertionFailedError.html. Apparently there’s a method: getMessage, try it, if you haven’t tried it already.
– mau humor
Junit can be extended in some ways, if your need is worth the effort... But suddenly there are simpler alternatives. For what you need to get this message in a string?
– Caffé
user5978, I couldn’t use getMessage. @Caffé I need to make a class evaluation system using Junit, and I need this message to appear in a notification window for the user.
– Araújo Filho