Does anyone know what the numbers 5b40c281 and 78a1d1f4 mean in the EasyMock test case fail shown below?
Are they essentially address pointers to two different instances of PdlPrintJob?
Does anyone know why this fail is occurring?
In the main code, PdlPrintJob is constructed (using new PdlPrintJob()) and passed as a parameter to method printer.executePrintJob().
In the test case, PdlPrintJob is constructed (using new PdlPrintJob()) and passed as a parameter to mockPrinter.executePrintJob().
Thanks for any advice,
Best regards
James
junit.framework.AssertionFailedError:
Unexpected method call executePrintJob(com.canon.cel.meap.jobs.PdlPrintJob@5b40c281, EasyMock for interface com.canon.meap.security.AccessControlToken):
executePrintJob(com.canon.cel.meap.jobs.PdlPrintJob@5b40c281, EasyMock for interface com.canon.meap.security.AccessControlToken): expected: 0, actual: 1
executePrintJob(com.canon.cel.meap.jobs.PdlPrintJob@78a1d1f4, EasyMock for interface com.canon.meap.security.AccessControlToken): expected: 1, actual: 0
Its because you have done something like this in your test class.
but actually it should have been a mockObject that you should have passed as parameter.
you need to do something like this
You were facing the issue because Easymock is a strict mocking framework, you had asked it to expect a particular method with particular object type only
(its like tightly binding method expectation to a single object)
, and during execution as new operator was used the method expectation failed as object parameters didnt match the expectation of Easymock, resulting in this exception.I always prefer doing something like this for method expectation
if my method to be tested is
I expect this method in easymock as follows:
so by this approach my method expectation works for any valid parameters passed to my compress() method during test case execution.
Hope that helps!
Good luck!