diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 69f8a38d..9cfe7434 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -95,7 +95,6 @@
-
diff --git a/mockito-kotlin/build.gradle b/mockito-kotlin/build.gradle
index 6c726dbe..1318ad55 100644
--- a/mockito-kotlin/build.gradle
+++ b/mockito-kotlin/build.gradle
@@ -27,7 +27,8 @@ dependencies {
compile "org.mockito:mockito-core:2.23.0"
- testCompile 'junit:junit:4.12'
+ testImplementation(platform('org.junit:junit-bom:5.7.1'))
+ testImplementation('org.junit.jupiter:junit-jupiter')
testCompile 'com.nhaarman:expect.kt:1.0.0'
testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@@ -36,6 +37,10 @@ dependencies {
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0"
}
+test {
+ useJUnitPlatform()
+}
+
dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/javadoc"
diff --git a/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt b/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt
index 5ca6eb66..be63407c 100644
--- a/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt
+++ b/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt
@@ -7,10 +7,9 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
-import org.junit.Test
+import org.junit.jupiter.api.Test
import org.mockito.kotlin.*
-
class CoroutinesTest {
@Test
diff --git a/tests/build.gradle b/tests/build.gradle
index 24ab716b..ea31eaa7 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -24,6 +24,14 @@ dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.mockito:mockito-core:2.23.0"
+ // only needed because "test.VerifyTest.verifyFailsWithWrongArg" checks for ArgumentsAreDifferent which inherits from JUnit 4 ComparisonFailure
testCompile "junit:junit:4.12"
+
+ testImplementation(platform("org.junit:junit-bom:5.7.1"))
+ testImplementation "org.junit.jupiter:junit-jupiter"
testCompile "com.nhaarman:expect.kt:1.0.0"
-}
\ No newline at end of file
+}
+
+test {
+ useJUnitPlatform()
+}
diff --git a/tests/src/test/kotlin/test/ArgumentCaptorTest.kt b/tests/src/test/kotlin/test/ArgumentCaptorTest.kt
index 703e7500..8c67ab0a 100644
--- a/tests/src/test/kotlin/test/ArgumentCaptorTest.kt
+++ b/tests/src/test/kotlin/test/ArgumentCaptorTest.kt
@@ -2,7 +2,8 @@ package test
import com.nhaarman.expect.expect
import com.nhaarman.expect.expectErrorWithMessage
-import org.junit.Test
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
import org.mockito.kotlin.*
import java.util.*
@@ -179,7 +180,7 @@ class ArgumentCaptorTest : TestBase() {
}
}
- @Test(expected = IndexOutOfBoundsException::class)
+ @Test
fun argumentCaptor_callPropertyNotAvailable() {
/* Given */
val m: Methods = mock()
@@ -188,10 +189,12 @@ class ArgumentCaptorTest : TestBase() {
m.int(1)
/* Then */
- argumentCaptor().apply {
- verify(m).int(capture())
+ Assertions.assertThrows(IndexOutOfBoundsException::class.java) {
+ argumentCaptor().apply {
+ verify(m).int(capture())
- expect(secondValue).toBe(2)
+ expect(secondValue).toBe(2)
+ }
}
}
diff --git a/tests/src/test/kotlin/test/BDDMockitoTest.kt b/tests/src/test/kotlin/test/BDDMockitoTest.kt
index 0472163f..efb91da0 100644
--- a/tests/src/test/kotlin/test/BDDMockitoTest.kt
+++ b/tests/src/test/kotlin/test/BDDMockitoTest.kt
@@ -1,7 +1,8 @@
package test
import com.nhaarman.expect.expect
-import org.junit.Test
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
import org.mockito.kotlin.*
import org.mockito.stubbing.Answer
@@ -106,14 +107,16 @@ class BDDMockitoTest {
expect(mock.stringResult("Test")).toBe("tseT")
}
- @Test(expected = IllegalStateException::class)
+ @Test
fun given_willThrowInfix_properlyStubs() {
/* Given */
val mock = mock()
/* When */
- given(mock.stringResult()) willThrow { IllegalStateException() }
- mock.stringResult()
+ Assertions.assertThrows(IllegalStateException::class.java) {
+ given(mock.stringResult()) willThrow { IllegalStateException() }
+ mock.stringResult()
+ }
}
@Test
diff --git a/tests/src/test/kotlin/test/EqTest.kt b/tests/src/test/kotlin/test/EqTest.kt
index 2f64c092..419b9339 100644
--- a/tests/src/test/kotlin/test/EqTest.kt
+++ b/tests/src/test/kotlin/test/EqTest.kt
@@ -26,11 +26,11 @@ package test
*/
import com.nhaarman.expect.expect
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.BeforeEach
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
+import org.junit.jupiter.api.Test
import org.mockito.Mockito
class EqTest : TestBase() {
@@ -41,13 +41,13 @@ class EqTest : TestBase() {
private lateinit var doAnswer: Open
- @Before
+ @BeforeEach
fun setup() {
/* Create a proper Mockito state */
doAnswer = Mockito.doAnswer { }.`when`(mock())
}
- @After
+ @AfterEach
override fun tearDown() {
super.tearDown()
diff --git a/tests/src/test/kotlin/test/MatchersTest.kt b/tests/src/test/kotlin/test/MatchersTest.kt
index afed69f8..118404dc 100644
--- a/tests/src/test/kotlin/test/MatchersTest.kt
+++ b/tests/src/test/kotlin/test/MatchersTest.kt
@@ -2,7 +2,7 @@ package test
import com.nhaarman.expect.expect
import com.nhaarman.expect.expectErrorWithMessage
-import org.junit.Test
+import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatcher
import org.mockito.internal.matchers.VarargMatcher
import org.mockito.invocation.InvocationOnMock
@@ -331,4 +331,4 @@ class MatchersTest : TestBase() {
override fun answer(i: InvocationOnMock) = if (anyMatched) success else failure
}
-}
\ No newline at end of file
+}
diff --git a/tests/src/test/kotlin/test/MockingTest.kt b/tests/src/test/kotlin/test/MockingTest.kt
index 43e64136..6741642c 100644
--- a/tests/src/test/kotlin/test/MockingTest.kt
+++ b/tests/src/test/kotlin/test/MockingTest.kt
@@ -9,7 +9,7 @@ import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
-import org.junit.Test
+import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.exceptions.verification.WantedButNotInvoked
import org.mockito.listeners.InvocationListener
@@ -354,4 +354,4 @@ class MockingTest : TestBase() {
private interface MyInterface
private open class MyClass
-}
\ No newline at end of file
+}
diff --git a/tests/src/test/kotlin/test/OngoingStubbingTest.kt b/tests/src/test/kotlin/test/OngoingStubbingTest.kt
index 3c9268e2..94fc669b 100644
--- a/tests/src/test/kotlin/test/OngoingStubbingTest.kt
+++ b/tests/src/test/kotlin/test/OngoingStubbingTest.kt
@@ -3,13 +3,12 @@ package test
import com.nhaarman.expect.expect
import com.nhaarman.expect.expectErrorWithMessage
import com.nhaarman.expect.fail
-import org.junit.Assume.assumeFalse
-import org.junit.Test
+import org.junit.jupiter.api.Assumptions.assumeFalse
+import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.exceptions.misusing.UnfinishedStubbingException
import org.mockito.kotlin.*
import org.mockito.stubbing.Answer
-import kotlin.check
class OngoingStubbingTest : TestBase() {
diff --git a/tests/src/test/kotlin/test/SpyTest.kt b/tests/src/test/kotlin/test/SpyTest.kt
index 500faeef..166db0be 100644
--- a/tests/src/test/kotlin/test/SpyTest.kt
+++ b/tests/src/test/kotlin/test/SpyTest.kt
@@ -26,8 +26,9 @@ package test
*/
import com.nhaarman.expect.expect
-import org.junit.After
-import org.junit.Test
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.kotlin.*
import java.util.*
@@ -38,7 +39,7 @@ class SpyTest : TestBase() {
private val openClassInstance: MyClass = MyClass()
private val closedClassInstance: ClosedClass = ClosedClass()
- @After
+ @AfterEach
override fun tearDown() {
super.tearDown()
Mockito.validateMockitoUsage()
@@ -77,11 +78,13 @@ class SpyTest : TestBase() {
expect(date.time).toBe(0L)
}
- @Test(expected = IllegalArgumentException::class)
+ @Test
fun doThrowWithSpy() {
val date = spy(Date(0))
- doThrow(IllegalArgumentException()).whenever(date).time
- date.time
+ Assertions.assertThrows(IllegalArgumentException::class.java) {
+ doThrow(IllegalArgumentException()).whenever(date).time
+ date.time
+ }
}
@Test
diff --git a/tests/src/test/kotlin/test/StubberTest.kt b/tests/src/test/kotlin/test/StubberTest.kt
index eb6e28cd..e6709285 100644
--- a/tests/src/test/kotlin/test/StubberTest.kt
+++ b/tests/src/test/kotlin/test/StubberTest.kt
@@ -2,7 +2,7 @@ package test
import com.nhaarman.expect.expect
import com.nhaarman.expect.expectErrorWithMessage
-import org.junit.Test
+import org.junit.jupiter.api.Test
import org.mockito.kotlin.*
class StubberTest : TestBase() {
@@ -100,4 +100,4 @@ class StubberTest : TestBase() {
mock.go()
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/src/test/kotlin/test/TestBase.kt b/tests/src/test/kotlin/test/TestBase.kt
index 95c76ece..55b0c7cb 100644
--- a/tests/src/test/kotlin/test/TestBase.kt
+++ b/tests/src/test/kotlin/test/TestBase.kt
@@ -1,11 +1,11 @@
package test
-import org.junit.After
+import org.junit.jupiter.api.AfterEach
abstract class TestBase {
- @After
+ @AfterEach
open fun tearDown() {
mockMakerInlineEnabled = null
}
-}
\ No newline at end of file
+}
diff --git a/tests/src/test/kotlin/test/VerificationTest.kt b/tests/src/test/kotlin/test/VerificationTest.kt
index f2f92fdf..9f2d9c78 100644
--- a/tests/src/test/kotlin/test/VerificationTest.kt
+++ b/tests/src/test/kotlin/test/VerificationTest.kt
@@ -1,7 +1,7 @@
package test
import com.nhaarman.expect.expect
-import org.junit.Test
+import org.junit.jupiter.api.Test
import org.mockito.exceptions.base.MockitoAssertionError
import org.mockito.kotlin.*
import org.mockito.kotlin.verify
@@ -112,4 +112,4 @@ class VerificationTest : TestBase() {
verify(this, after(10)).int(3)
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/src/test/kotlin/test/VerifyTest.kt b/tests/src/test/kotlin/test/VerifyTest.kt
index 0a93832a..1bc043bf 100644
--- a/tests/src/test/kotlin/test/VerifyTest.kt
+++ b/tests/src/test/kotlin/test/VerifyTest.kt
@@ -1,9 +1,10 @@
package test
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
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.junit.ArgumentsAreDifferent
@@ -30,25 +31,29 @@ class VerifyTest : TestBase() {
}
}
- @Test(expected = TooLittleActualInvocations::class)
+ @Test
fun verifyFailsWithWrongCount() {
val iface = mock()
iface.call(0)
- verify(iface) {
- 2 * { call(0) }
+ Assertions.assertThrows(TooLittleActualInvocations::class.java) {
+ verify(iface) {
+ 2 * { call(0) }
+ }
}
}
- @Test(expected = ArgumentsAreDifferent::class)
+ @Test
fun verifyFailsWithWrongArg() {
val iface = mock()
iface.call(3)
- verify(iface) {
- 1 * { call(0) }
+ Assertions.assertThrows(ArgumentsAreDifferent::class.java) {
+ verify(iface) {
+ 1 * { call(0) }
+ }
}
}
@@ -93,4 +98,4 @@ class VerifyTest : TestBase() {
fun defaultArgs(a: Int = 3, b: Int = 42)
}
-}
\ No newline at end of file
+}
diff --git a/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt b/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt
index 6d160c78..e8e92feb 100644
--- a/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt
+++ b/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt
@@ -1,11 +1,10 @@
package test.createinstance
import com.nhaarman.expect.expect
+import org.junit.jupiter.api.Test
import org.mockito.kotlin.internal.createInstance
-import org.junit.Test
import test.TestBase
-
class NullCasterTest : TestBase() {
@Test
diff --git a/tests/src/test/kotlin/test/inline/UsingMockMakerInlineTest.kt b/tests/src/test/kotlin/test/inline/UsingMockMakerInlineTest.kt
index b03d77ea..a9c3229e 100644
--- a/tests/src/test/kotlin/test/inline/UsingMockMakerInlineTest.kt
+++ b/tests/src/test/kotlin/test/inline/UsingMockMakerInlineTest.kt
@@ -23,9 +23,9 @@
*/
import com.nhaarman.expect.expect
-import org.junit.Assume.assumeTrue
-import org.junit.Before
-import org.junit.Test
+import org.junit.jupiter.api.Assumptions.assumeTrue
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
import org.mockito.kotlin.*
import test.mockMakerInlineEnabled
import java.io.IOException
@@ -43,7 +43,7 @@ class UsingMockMakerInlineTest {
}
}
- @Before
+ @BeforeEach
fun setup() {
mockMakerInlineEnabled = null
assumeTrue(mockMakerInlineEnabled())