First time using JUnit and so far its been pretty good. In a test I am expecting a number to be 128. I specify this in the code as:
assertEquals(myclass.myVar(), 228);
However I get such an odd error from JUnit:
expected:<418> but was:<228>
junit.framework.AssertionFailedError: expected:<418> but was:<228>
So the program is giving me the right output. Which I have checked without JUnit just to make sure. But the test is failing. Could anyone shed some light on where its getting the 418 number from? I’ve not specified it anywhere in the Junit test file at all.
TIA
You’ve got your arguments the wrong way round. It should be:
So your test should be:
At that point you’ll get a more reasonable message – and then you need to work out why
myVar()is actually returning 418 🙂