Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated verifyZeroInteractions #447

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
13 changes: 0 additions & 13 deletions mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 10 additions & 2 deletions tests/src/test/kotlin/test/MockingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -182,7 +184,10 @@ class MockingTest : TestBase() {
fail("Expected an exception")
} catch (e: WantedButNotInvoked) {
/* Then */
verify(out).println("methods.stringResult();")
argumentCaptor<DescribedInvocation>().apply {
verify(out).println(capture())
expect(lastValue.toString()).toBe("methods.stringResult();")
}
Comment on lines -185 to +190
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Mockito 2.23.0, println used to be called with a string, but in 4.0.0 it's called with a DescribedInvocation directly.

What do you think about checking the value like this? It didn't seem like it would be simple to create an InterceptedInvocation to use for the test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that seems good to me 👍

}
}

Expand Down Expand Up @@ -314,7 +319,10 @@ class MockingTest : TestBase() {
fail("Expected an exception")
} catch (e: WantedButNotInvoked) {
/* Then */
verify(out).println("methods.stringResult();")
argumentCaptor<DescribedInvocation>().apply {
verify(out).println(capture())
expect(lastValue.toString()).toBe("methods.stringResult();")
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/kotlin/test/VerifyTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -30,7 +30,7 @@ class VerifyTest : TestBase() {
}
}

@Test(expected = TooLittleActualInvocations::class)
@Test(expected = TooFewActualInvocations::class)
fun verifyFailsWithWrongCount() {
val iface = mock<TestInterface>()

Expand Down