Skip to content

Commit

Permalink
mockito#2522: Add a new test subproject to verify fixes between mocki…
Browse files Browse the repository at this point in the history
…to-inline and Groovy
  • Loading branch information
Steve Green authored and Steve Green committed Feb 15, 2022
1 parent 43ac1c8 commit b9f01a8
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 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
Expand Up @@ -12,12 +12,9 @@
import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.hasParameters;
import static net.bytebuddy.matcher.ElementMatchers.hasType;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
import static net.bytebuddy.matcher.ElementMatchers.isEquals;
import static net.bytebuddy.matcher.ElementMatchers.isHashCode;
import static net.bytebuddy.matcher.ElementMatchers.isPackagePrivate;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import static net.bytebuddy.matcher.ElementMatchers.whereAny;
import static org.mockito.internal.util.StringUtil.join;
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 b9f01a8

Please sign in to comment.