Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix verifyNoMoreInteractions inOrder invocations for spies
Fixes #2394
- Loading branch information
1 parent
a53c3d4
commit 8f18142
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/test/java/org/mockitousage/spies/SpiesWithRealEqualsAndInOrderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2021 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitousage.spies; | ||
|
||
import static org.mockito.Mockito.spy; | ||
import static org.mockito.Mockito.inOrder; | ||
|
||
import org.junit.Test; | ||
import org.mockito.InOrder; | ||
|
||
// https://github.com/mockito/mockito/issues/2394 | ||
public class SpiesWithRealEqualsAndInOrderTest { | ||
|
||
@Test | ||
public void should_be_able_to_handle_in_order_on_spies_with_equals() { | ||
ToBeSpied mock1 = spy(new ToBeSpied()); | ||
ToBeSpied mock2 = spy(new ToBeSpied()); | ||
mock1.someMethod(); | ||
InOrder order = inOrder(mock1, mock2); | ||
order.verify(mock1).someMethod(); | ||
order.verifyNoMoreInteractions(); | ||
} | ||
|
||
static class ToBeSpied { | ||
void someMethod() {} | ||
} | ||
} |