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.
mockito#2522: Add a new test subproject to verify fixes between mocki…
…to-inline and Groovy
- Loading branch information
Steve Green
authored and
Steve Green
committed
Feb 15, 2022
1 parent
43ac1c8
commit b9f01a8
Showing
4 changed files
with
58 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apply plugin: 'groovy' | ||
|
||
description = "Integration test for using mockito-inline with Groovy." | ||
|
||
apply from: "$rootDir/gradle/dependencies.gradle" | ||
|
||
dependencies { | ||
testImplementation project(":inline") | ||
testImplementation libraries.groovy | ||
testImplementation libraries.junit4 | ||
} |
46 changes: 46 additions & 0 deletions
46
subprojects/groovyInlineTest/src/test/groovy/org/mockito/groovy/GroovyMockitoTest.groovy
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,46 @@ | ||
/* | ||
* Copyright (c) 2022 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockito.groovy | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.InjectMocks | ||
import org.mockito.Mock | ||
import org.mockito.junit.MockitoJUnitRunner | ||
|
||
import static org.mockito.Mockito.verify | ||
|
||
@RunWith(MockitoJUnitRunner) | ||
class GroovyMockitoTest { | ||
|
||
@Mock Helper helper | ||
@InjectMocks ClassUnderTest classUnderTest | ||
|
||
/** | ||
* Test that the Groovy class under test can call methods on a mocked Groovy | ||
* helper class. | ||
*/ | ||
@Test | ||
void testCallGroovyFromGroovy() { | ||
classUnderTest.methodUnderTest() | ||
verify(helper).helperMethod() | ||
} | ||
|
||
static class ClassUnderTest { | ||
private final Helper helper | ||
|
||
ClassUnderTest(Helper helper) { | ||
this.helper = helper | ||
} | ||
|
||
void methodUnderTest() { | ||
helper.helperMethod() | ||
} | ||
} | ||
|
||
static class Helper { | ||
void helperMethod() { } | ||
} | ||
} |