Skip to content

Commit

Permalink
Update mockito-core to 4.0.0 (#447)
Browse files Browse the repository at this point in the history
This also removes `verifyZeroInteractions`, which was removed in Mockito 4.

Fixes #446.
  • Loading branch information
rashadsookram committed Oct 8, 2021
1 parent b96b5ce commit 7f1d094
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
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();")
}
}
}

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

0 comments on commit 7f1d094

Please sign in to comment.