-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3229: Resolve test generic arguments
- Loading branch information
1 parent
9972676
commit 915f9c8
Showing
3 changed files
with
57 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
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
37 changes: 37 additions & 0 deletions
37
...-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,37 @@ | ||
/* | ||
* Copyright (c) 2024 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockitousage.annotation; | ||
|
||
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.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()); | ||
} | ||
} |