Skip to content
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
537 changes: 0 additions & 537 deletions mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt

This file was deleted.

2 changes: 1 addition & 1 deletion tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {

testImplementation 'junit:junit:4.13.2'
testImplementation "com.nhaarman:expect.kt:1.0.1"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0-RC"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2"
}

tasks.withType(KotlinCompile).configureEach {
Expand Down
36 changes: 18 additions & 18 deletions tests/src/test/kotlin/test/AdditionalMatchersTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testGeq() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(1)
verify(this).int(geq(0))
verify(this).int(geq(1))
Expand All @@ -17,7 +17,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testLeq() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(1)
verify(this).int(leq(2))
verify(this).int(leq(1))
Expand All @@ -27,7 +27,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testGt() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(1)
verify(this).int(gt(0))
verify(this, never()).int(gt(1))
Expand All @@ -36,7 +36,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testLt() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(1)
verify(this).int(lt(2))
verify(this, never()).int(lt(1))
Expand All @@ -45,7 +45,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testCmpEq() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(1)
verify(this).int(cmpEq(1))
verify(this, never()).int(cmpEq(2))
Expand All @@ -54,7 +54,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqBoolean() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
booleanArray(booleanArrayOf(true, false, true))
verify(this).booleanArray(aryEq(booleanArrayOf(true, false, true)))
verify(this, never()).booleanArray(aryEq(booleanArrayOf(true, false)))
Expand All @@ -63,7 +63,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqByte() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
byteArray(byteArrayOf(1, 2, 3))
verify(this).byteArray(aryEq(byteArrayOf(1, 2, 3)))
verify(this, never()).byteArray(aryEq(byteArrayOf(1, 2)))
Expand All @@ -72,7 +72,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqShort() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
shortArray(shortArrayOf(1, 2, 3))
verify(this).shortArray(aryEq(shortArrayOf(1, 2, 3)))
verify(this, never()).shortArray(aryEq(shortArrayOf(1, 2)))
Expand All @@ -81,7 +81,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqInt() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
intArray(intArrayOf(1, 2, 3))
verify(this).intArray(aryEq(intArrayOf(1, 2, 3)))
verify(this, never()).intArray(aryEq(intArrayOf(1, 2)))
Expand All @@ -90,7 +90,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqLong() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
longArray(longArrayOf(1, 2, 3))
verify(this).longArray(aryEq(longArrayOf(1, 2, 3)))
verify(this, never()).longArray(aryEq(longArrayOf(1, 2)))
Expand All @@ -99,7 +99,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqChar() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
charArray(charArrayOf('1', '2', '3'))
verify(this).charArray(aryEq(charArrayOf('1', '2', '3')))
verify(this, never()).charArray(aryEq(charArrayOf('1', '2')))
Expand All @@ -108,7 +108,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqFloat() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
floatArray(floatArrayOf(1f, 2f, 3.4f))
verify(this).floatArray(aryEq(floatArrayOf(1f, 2f, 3.4f)))
verify(this, never()).floatArray(aryEq(floatArrayOf(1f, 2f)))
Expand All @@ -117,7 +117,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEqDouble() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
doubleArray(doubleArrayOf(1.0, 2.0, 3.4))
verify(this).doubleArray(aryEq(doubleArrayOf(1.0, 2.0, 3.4)))
verify(this, never()).doubleArray(aryEq(doubleArrayOf(1.0, 2.0)))
Expand All @@ -126,7 +126,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAryEq() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
stringArray(arrayOf("Hello", "there"))
verify(this).stringArray(aryEq(arrayOf("Hello", "there")))
verify(this, never()).stringArray(aryEq(arrayOf("Hello")))
Expand All @@ -135,7 +135,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testFind() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
string("Hello")
verify(this).string(find("l+o$".toRegex()))
verify(this, never()).string(find("l$".toRegex()))
Expand All @@ -144,7 +144,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testAnd() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(5)
verify(this).int(and(geq(4), leq(6)))
verify(this, never()).int(and(geq(4), leq(4)))
Expand All @@ -153,7 +153,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testOr() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(5)
verify(this).int(and(gt(4), lt(6)))
verify(this, never()).int(and(gt(4), lt(4)))
Expand All @@ -162,7 +162,7 @@ class AdditionalCaptorsTest : TestBase() {

@Test
fun testNot() {
mock<Methods>().apply {
mock<SynchronousFunctions>().apply {
int(5)
verify(this).int(not(eq(4)))
verify(this, never()).int(not(eq(5)))
Expand Down
28 changes: 14 additions & 14 deletions tests/src/test/kotlin/test/ArgumentCaptorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_withNullValue_usingNonNullable() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.nullableString(null)
Expand All @@ -115,7 +115,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_withNullValue_usingNullable() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.nullableString(null)
Expand Down Expand Up @@ -173,7 +173,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_multipleValuesIncludingNull() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.nullableString("test")
Expand All @@ -188,7 +188,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_callProperties() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.int(1)
Expand All @@ -211,7 +211,7 @@ class ArgumentCaptorTest : TestBase() {
@Test(expected = IndexOutOfBoundsException::class)
fun argumentCaptor_callPropertyNotAvailable() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.int(1)
Expand Down Expand Up @@ -259,7 +259,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_vararg() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.varargBooleanResult("a", "b", "c")
Expand All @@ -273,7 +273,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_empty_vararg() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.varargBooleanResult()
Expand All @@ -287,7 +287,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_arg_vararg() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.argAndVararg("first", "a", "b", "c")
Expand All @@ -301,7 +301,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_intarray() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.intArray(intArrayOf(1, 2, 3))
Expand All @@ -315,7 +315,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_array() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.stringArray(arrayOf("a", "b", "c"))
Expand All @@ -329,7 +329,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_empty_array() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.stringArray(arrayOf())
Expand All @@ -343,7 +343,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_value_class() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()
val valueClass = ValueClass("Content")

/* When */
Expand All @@ -358,7 +358,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_value_class_withNullValue_usingNonNullable() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.nullableValueClass(null)
Expand All @@ -372,7 +372,7 @@ class ArgumentCaptorTest : TestBase() {
@Test
fun argumentCaptor_value_class_withNullValue_usingNullable() {
/* Given */
val m: Methods = mock()
val m: SynchronousFunctions = mock()

/* When */
m.nullableValueClass(null)
Expand Down
22 changes: 11 additions & 11 deletions tests/src/test/kotlin/test/BDDMockitoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BDDMockitoTest {
@Test
fun given_will_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given(mock.stringResult()) will Answer<String> { "Test" }
Expand All @@ -22,7 +22,7 @@ class BDDMockitoTest {
@Test
fun given_willReturn_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given(mock.stringResult()).willReturn("Test")
Expand All @@ -34,7 +34,7 @@ class BDDMockitoTest {
@Test
fun givenLambda_willReturn_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given { mock.stringResult() }.willReturn("Test")
Expand All @@ -46,7 +46,7 @@ class BDDMockitoTest {
@Test
fun given_willReturnLambda_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given(mock.stringResult()).willReturn { "Test" }
Expand All @@ -58,7 +58,7 @@ class BDDMockitoTest {
@Test
fun givenLambda_willReturnLambda_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given { mock.stringResult() } willReturn { "Test" }
Expand All @@ -70,7 +70,7 @@ class BDDMockitoTest {
@Test
fun given_willAnswer_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given(mock.stringResult()).willAnswer { "Test" }
Expand All @@ -82,7 +82,7 @@ class BDDMockitoTest {
@Test
fun given_willAnswerInfix_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given(mock.stringResult()) willAnswer { "Test" }
Expand All @@ -94,7 +94,7 @@ class BDDMockitoTest {
@Test
fun given_willAnswerInfix_withInvocationInfo_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given(mock.stringResult(any())) willAnswer { invocation ->
Expand All @@ -109,7 +109,7 @@ class BDDMockitoTest {
@Test(expected = IllegalStateException::class)
fun given_willThrowInfix_properlyStubs() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()

/* When */
given(mock.stringResult()) willThrow { IllegalStateException() }
Expand All @@ -119,13 +119,13 @@ class BDDMockitoTest {
@Test
fun then() {
/* Given */
val mock = mock<Methods>()
val mock = mock<SynchronousFunctions>()
whenever(mock.stringResult()).thenReturn("Test")

/* When */
mock.stringResult()

/* Then */
org.mockito.kotlin.then(mock).should().stringResult()
then(mock).should().stringResult()
}
}
Loading