When a mock is passed to a component that uses the
component in separate thread(s) calls can be made to
the mock outside of the rMock test cases syncronisation
points (startVerification() and end of the test case).
This can probably cause the following problems:
* UnsatisfiedExpectationsException if the call is made
before startVerification() (the call will be considered
a setup call).
* UnexpectedInvocationException when the call is made
after startVerification() and before the test is finished.
* UnexpectedInvocationException when the call is made
after the test is finished (this is the discovered
behaviour so far). In this case the call seems to not
fail the testcase, but will print out the failure in
the standard way.
* Non-deterministic testing results overall
E.g. Swing components and AWT-EventThreads that behaves
differently on different platforms can give this
behaviour in an extra non-deterministic way.
Generally, one should be very careful when testing
components that spawns threads that uses mocks. RMock
is not yet designed or tested for a threaded
environment, but any input here will be appreciated.
Suggested solution (cure the symptoms):
Null all mocks connections to the expectations/the
enging when a testcase ends, hence not passing calls to
validate them.
Any input on alternative solutions are much appreciated.
Cheers
Daniel
Logged In: YES
user_id=642837
The suggested solution will only cure the verified symptoms
(i.e. when a call is made after the test case has finished),
not the whole list of probable symptoms.
Cheers
Daniel