Skip to content

Commit 4c7c942

Browse files
authored
Merge pull request #154 from nhaarman/release-1.3.0
Release 1.3.0
2 parents 6330fe3 + 87e0da2 commit 4c7c942

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ matrix:
77
- jdk: oraclejdk7
88
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.0.6
99
- jdk: oraclejdk7
10-
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.0-beta-18
10+
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.0-beta-38
1111
- jdk: oraclejdk8
1212
env: TERM=dumb KOTLIN_VERSION=1.0.6
1313
- jdk: oraclejdk8
14-
env: TERM=dumb KOTLIN_VERSION=1.1.0-beta-18
14+
env: TERM=dumb KOTLIN_VERSION=1.1.0-beta-38
1515

1616

1717
env:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'com.github.ben-manes.versions' version '0.13.0'
2+
id 'com.github.ben-manes.versions' version '0.14.0'
33
}
44

55
apply from: 'gradle/scripts/tagging.gradle'

mockito-kotlin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repositories {
2828
dependencies {
2929
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3030
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
31-
compile "org.mockito:mockito-core:2.6.5"
31+
compile "org.mockito:mockito-core:2.7.5"
3232

3333
/* Tests */
3434
testCompile "junit:junit:4.12"

mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/Mockito.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ fun <T> OngoingStubbing<T>.doThrow(t: Throwable, vararg ts: Throwable): OngoingS
224224
infix fun <T> OngoingStubbing<T>.doThrow(t: KClass<out Throwable>): OngoingStubbing<T> = thenThrow(t.java)
225225
fun <T> OngoingStubbing<T>.doThrow(t: KClass<out Throwable>, vararg ts: KClass<out Throwable>): OngoingStubbing<T> = thenThrow(t.java, *ts.map { it.java }.toTypedArray())
226226

227+
infix fun <T> OngoingStubbing<T>.doAnswer(answer: (InvocationOnMock) -> T?): OngoingStubbing<T> = thenAnswer(answer)
228+
227229
fun mockingDetails(toInspect: Any): MockingDetails = Mockito.mockingDetails(toInspect)!!
228230
fun never(): VerificationMode = Mockito.never()!!
229231
fun <T : Any> notNull(): T? = Mockito.notNull()

mockito-kotlin/src/test/kotlin/test/MockitoTest.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,34 @@ class MockitoTest : TestBase() {
488488
}
489489
}
490490

491+
@Test
492+
fun testMockStubbing_doAnswer() {
493+
/* Given */
494+
val mock = mock<Methods> {
495+
on { stringResult() } doAnswer { "result" }
496+
}
497+
498+
/* When */
499+
val result = mock.stringResult()
500+
501+
/* Then */
502+
expect(result).toBe("result")
503+
}
504+
505+
@Test
506+
fun testMockStubbing_doAnswer_withArgument() {
507+
/* Given */
508+
val mock = mock<Methods> {
509+
on { stringResult(any()) } doAnswer { "${it.arguments[0]}-result" }
510+
}
511+
512+
/* When */
513+
val result = mock.stringResult("argument")
514+
515+
/* Then */
516+
expect(result).toBe("argument-result")
517+
}
518+
491519
@Test
492520
fun mock_withCustomName() {
493521
/* Given */

0 commit comments

Comments
 (0)