Get/save parameters to an expected JMock method call?
Posted
by Tayeb
on Stack Overflow
See other posts from Stack Overflow
or by Tayeb
Published on 2009-01-05T15:46:56Z
Indexed on
2010/05/09
13:08 UTC
Read the original article
Hit count: 217
jmock
|unit-testing
Hi,
I want to test an "Adapter" object that when it receives an xml message, it digest it to a Message object, puts message ID + CorrelationID both with timestamps and forwards it to a Client object.=20 A message can be correlated to a previous one (e.g. m2.correlationID =3D m1.ID).
I mock the Client, and check that Adapter successfully calls "client.forwardMessage(m)" twice with first message with null correlationID, and a second with a not-null correlationID.
However, I would like to precisely test that the correlationIDs are set correctly, by grabing the IDs (e.g. m1.ID).
But I couldn't find anyway to do so.
There is a jira about adding the feature, but no one commented and it is unassigned.
Is this really unimplemented?
I read about the alternative of redesigning the Adapter to use an IdGenerator object, which I can stub, but I think there will be too many objects.=20 Don't you think it adds unnecessary complexity to split objects to a so fine granularity?
Thanks, and I appreciate any comments :-)
Tayeb
© Stack Overflow or respective owner