Skip to content

Commit 7f1d094

Browse files
Update mockito-core to 4.0.0 (#447)
This also removes `verifyZeroInteractions`, which was removed in Mockito 4. Fixes #446.
1 parent b96b5ce commit 7f1d094

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

mockito-kotlin/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies {
2525
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
2626
compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0'
2727

28-
compile "org.mockito:mockito-core:3.12.4"
28+
compile "org.mockito:mockito-core:4.0.0"
2929

3030
testCompile 'junit:junit:4.12'
3131
testCompile 'com.nhaarman:expect.kt:1.0.0'

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt

-13
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,6 @@ fun verifyNoInteractions(vararg mocks: Any) {
9090
Mockito.verifyNoInteractions(*mocks)
9191
}
9292

93-
/**
94-
* @deprecated
95-
*
96-
* Please migrate your code to [verifyNoInteractions].
97-
*/
98-
@Deprecated(
99-
"Use verifyNoInteractions() instead.",
100-
ReplaceWith("verifyNoInteractions(vararg mocks: Any)")
101-
)
102-
fun verifyZeroInteractions(vararg mocks: Any) {
103-
Mockito.verifyZeroInteractions(*mocks)
104-
}
105-
10693
/**
10794
* Allows verifying exact number of invocations.
10895
*

tests/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222
compile files("${rootProject.projectDir}/mockito-kotlin/build/libs/mockito-kotlin-${version}.jar")
2323

2424
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
25-
compile "org.mockito:mockito-core:2.23.0"
25+
compile "org.mockito:mockito-core:4.0.0"
2626

2727
testCompile "junit:junit:4.12"
2828
testCompile "com.nhaarman:expect.kt:1.0.0"

tests/src/test/kotlin/test/MockingTest.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import org.mockito.kotlin.whenever
1212
import org.junit.Test
1313
import org.mockito.Mockito
1414
import org.mockito.exceptions.verification.WantedButNotInvoked
15+
import org.mockito.invocation.DescribedInvocation
16+
import org.mockito.kotlin.argumentCaptor
1517
import org.mockito.listeners.InvocationListener
1618
import org.mockito.mock.SerializableMode.BASIC
1719
import java.io.PrintStream
@@ -182,7 +184,10 @@ class MockingTest : TestBase() {
182184
fail("Expected an exception")
183185
} catch (e: WantedButNotInvoked) {
184186
/* Then */
185-
verify(out).println("methods.stringResult();")
187+
argumentCaptor<DescribedInvocation>().apply {
188+
verify(out).println(capture())
189+
expect(lastValue.toString()).toBe("methods.stringResult();")
190+
}
186191
}
187192
}
188193

@@ -314,7 +319,10 @@ class MockingTest : TestBase() {
314319
fail("Expected an exception")
315320
} catch (e: WantedButNotInvoked) {
316321
/* Then */
317-
verify(out).println("methods.stringResult();")
322+
argumentCaptor<DescribedInvocation>().apply {
323+
verify(out).println(capture())
324+
expect(lastValue.toString()).toBe("methods.stringResult();")
325+
}
318326
}
319327
}
320328

tests/src/test/kotlin/test/VerifyTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.mockito.kotlin.any
44
import org.mockito.kotlin.mock
55
import org.mockito.kotlin.verify
66
import org.junit.Test
7-
import org.mockito.exceptions.verification.TooLittleActualInvocations
7+
import org.mockito.exceptions.verification.TooFewActualInvocations
88
import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent
99

1010
class VerifyTest : TestBase() {
@@ -30,7 +30,7 @@ class VerifyTest : TestBase() {
3030
}
3131
}
3232

33-
@Test(expected = TooLittleActualInvocations::class)
33+
@Test(expected = TooFewActualInvocations::class)
3434
fun verifyFailsWithWrongCount() {
3535
val iface = mock<TestInterface>()
3636

0 commit comments

Comments
 (0)