Skip to content

Commit 6a8a111

Browse files
committed
TestsShouldIncludeAssertions: Allow more Mockito.verify*() methods
Fixes: #402
1 parent 33422a9 commit 6a8a111

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public class TestsShouldIncludeAssertions extends Recipe {
4242
"org.junit.jupiter.api.Assertions",
4343
"org.hamcrest.MatcherAssert",
4444
"org.mockito.Mockito.verify",
45+
"org.mockito.Mockito.verifyNoInteractions",
46+
"org.mockito.Mockito.verifyNoMoreInteractions",
47+
"org.mockito.Mockito.verifyZeroInteractions",
4548
"org.easymock",
4649
"org.jmock",
4750
"mockit",

src/test/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertionsTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,35 @@ public void verifyTest() {
300300
);
301301
}
302302

303+
@Test
304+
void hasMockitoVerifyNoInteractions() {
305+
//language=java
306+
rewriteRun(
307+
java(
308+
"""
309+
import org.junit.jupiter.api.Test;
310+
import org.mockito.Mock;
311+
import static org.mockito.Mockito.*;
312+
313+
class AaTest {
314+
@Mock
315+
org.learning.math.MyMathService myMathService;
316+
317+
@Test
318+
public void noMore() {
319+
verifyNoMoreInteractions(myMathService);
320+
}
321+
322+
@Test
323+
public void zero() {
324+
verifyZeroInteractions(myMathService);
325+
}
326+
}
327+
"""
328+
)
329+
);
330+
}
331+
303332
@Test
304333
void hasMockitoDoesNotValidate() {
305334
//language=java

0 commit comments

Comments
 (0)