Skip to content

@MockitoSpyBean does not see the first interactionΒ #33986

@McKratt

Description

@McKratt

Hello,

I just migrate a working code from 3.3.2 to 3.4.0 and when I change my tests to use the new @MockitoSpyBean I got exceptions with Mockito telling me that there is not the expected interaction with my mock. I cannot produce code easily, but here the exception :

Wanted but not invoked:
clientInitiator.start();
-> at quickfix.ThreadedSocketInitiator.start(ThreadedSocketInitiator.java:112)

However, there were exactly 3 interactions with this mock:
clientInitiator.startInitiators();
-> at quickfix.ThreadedSocketInitiator.start(ThreadedSocketInitiator.java:114)

clientInitiator.startSessionTimer();
-> at quickfix.mina.initiator.AbstractSocketInitiator.startInitiators(AbstractSocketInitiator.java:317)

clientInitiator.isLoggedOn();
-> at com.pictet.trading.gateway.FixToHttpIT.should_send_message_in_http(FixToHttpIT.java:133)

Here an extract of the code the producing the exception :

@MockitoSpyBean(name = "clientInitiator")
private Initiator initiator;
...
 then(initiator).should().start();

The actual class on Github : https://github.com/quickfix-j/quickfixj/blob/QFJ_RELEASE_2_3_1/quickfixj-core/src/main/java/quickfix/ThreadedSocketInitiator.java#L111

As you can see you cannot call startInitiators() without calling start().

If I put back @SpyBean then everything works !

Thank you in advance for your help πŸ™πŸ»

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: duplicateA duplicate of another issuetype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions