From 17279519215b02f3bd885507cb70e57ec44d6953 Mon Sep 17 00:00:00 2001 From: Rashad Sookram Date: Fri, 8 Oct 2021 12:34:02 -0400 Subject: [PATCH] Remove verifyZeroInteractions + bump mockito-core ... to 4.0.0. Fixes #446. --- mockito-kotlin/build.gradle | 2 +- .../main/kotlin/org/mockito/kotlin/Verification.kt | 13 ------------- tests/build.gradle | 2 +- tests/src/test/kotlin/test/MockingTest.kt | 12 ++++++++++-- tests/src/test/kotlin/test/VerifyTest.kt | 4 ++-- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/mockito-kotlin/build.gradle b/mockito-kotlin/build.gradle index 886fe42f..786e3346 100644 --- a/mockito-kotlin/build.gradle +++ b/mockito-kotlin/build.gradle @@ -25,7 +25,7 @@ dependencies { compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0' - compile "org.mockito:mockito-core:3.12.4" + compile "org.mockito:mockito-core:4.0.0" testCompile 'junit:junit:4.12' testCompile 'com.nhaarman:expect.kt:1.0.0' diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt index 074e9b56..2a16d0cb 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt @@ -90,19 +90,6 @@ fun verifyNoInteractions(vararg mocks: Any) { Mockito.verifyNoInteractions(*mocks) } -/** - * @deprecated - * - * Please migrate your code to [verifyNoInteractions]. - */ -@Deprecated( - "Use verifyNoInteractions() instead.", - ReplaceWith("verifyNoInteractions(vararg mocks: Any)") -) -fun verifyZeroInteractions(vararg mocks: Any) { - Mockito.verifyZeroInteractions(*mocks) -} - /** * Allows verifying exact number of invocations. * diff --git a/tests/build.gradle b/tests/build.gradle index 24ab716b..f263cb4f 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -22,7 +22,7 @@ dependencies { compile files("${rootProject.projectDir}/mockito-kotlin/build/libs/mockito-kotlin-${version}.jar") compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.mockito:mockito-core:2.23.0" + compile "org.mockito:mockito-core:4.0.0" testCompile "junit:junit:4.12" testCompile "com.nhaarman:expect.kt:1.0.0" diff --git a/tests/src/test/kotlin/test/MockingTest.kt b/tests/src/test/kotlin/test/MockingTest.kt index 43e64136..f0f9f64a 100644 --- a/tests/src/test/kotlin/test/MockingTest.kt +++ b/tests/src/test/kotlin/test/MockingTest.kt @@ -12,6 +12,8 @@ import org.mockito.kotlin.whenever import org.junit.Test import org.mockito.Mockito import org.mockito.exceptions.verification.WantedButNotInvoked +import org.mockito.invocation.DescribedInvocation +import org.mockito.kotlin.argumentCaptor import org.mockito.listeners.InvocationListener import org.mockito.mock.SerializableMode.BASIC import java.io.PrintStream @@ -182,7 +184,10 @@ class MockingTest : TestBase() { fail("Expected an exception") } catch (e: WantedButNotInvoked) { /* Then */ - verify(out).println("methods.stringResult();") + argumentCaptor().apply { + verify(out).println(capture()) + expect(lastValue.toString()).toBe("methods.stringResult();") + } } } @@ -314,7 +319,10 @@ class MockingTest : TestBase() { fail("Expected an exception") } catch (e: WantedButNotInvoked) { /* Then */ - verify(out).println("methods.stringResult();") + argumentCaptor().apply { + verify(out).println(capture()) + expect(lastValue.toString()).toBe("methods.stringResult();") + } } } diff --git a/tests/src/test/kotlin/test/VerifyTest.kt b/tests/src/test/kotlin/test/VerifyTest.kt index 0a93832a..1af73fdf 100644 --- a/tests/src/test/kotlin/test/VerifyTest.kt +++ b/tests/src/test/kotlin/test/VerifyTest.kt @@ -4,7 +4,7 @@ import org.mockito.kotlin.any import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.junit.Test -import org.mockito.exceptions.verification.TooLittleActualInvocations +import org.mockito.exceptions.verification.TooFewActualInvocations import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent class VerifyTest : TestBase() { @@ -30,7 +30,7 @@ class VerifyTest : TestBase() { } } - @Test(expected = TooLittleActualInvocations::class) + @Test(expected = TooFewActualInvocations::class) fun verifyFailsWithWrongCount() { val iface = mock()