forked from mockito/mockito
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes mockito#3229: Resolve test generic arguments
- Loading branch information
1 parent
9972676
commit 11994e1
Showing
2 changed files
with
39 additions
and
1 deletion.
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
38 changes: 38 additions & 0 deletions
38
...-jupiter/src/test/java/org/mockitousage/annotation/CaptorAnnotationWithPrimitiveTest.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,38 @@ | ||
package org.mockitousage.annotation; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Captor; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.doNothing; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class CaptorAnnotationWithPrimitiveTest { | ||
@Mock | ||
private Foo foo; | ||
|
||
static class Foo { | ||
void doSomething(int value) { | ||
} | ||
} | ||
|
||
@Test | ||
public void shouldCaptorPrimitive(@Captor ArgumentCaptor<Integer> captor) { | ||
// Given | ||
int value = 1; | ||
|
||
// When | ||
doNothing().when(foo).doSomething(captor.capture()); | ||
|
||
// Then | ||
foo.doSomething(value); | ||
assertEquals(1, captor.getValue()); | ||
} | ||
} |