Skip to content

Commit

Permalink
#2522: Add a new test subproject to verify fixes between mockito-inli…
Browse files Browse the repository at this point in the history
…ne and Groovy
  • Loading branch information
Steve Green authored and raphw committed Apr 13, 2022
1 parent 9fb58ae commit a11dbea
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions settings.gradle.kts
Expand Up @@ -6,6 +6,7 @@ include("inline",
"proxy",
"extTest",
"groovyTest",
"groovyInlineTest",
"kotlinTest",
"kotlinReleaseCoroutinesTest",
"android",
Expand Down
11 changes: 11 additions & 0 deletions subprojects/groovyInlineTest/groovyInlineTest.gradle
@@ -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
}
@@ -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() { }
}
}

0 comments on commit a11dbea

Please sign in to comment.