Skip to content

Commit

Permalink
Merge pull request #154 from nhaarman/release-1.3.0
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
nhaarman committed Feb 11, 2017
2 parents 6330fe3 + 87e0da2 commit 4c7c942
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ matrix:
- jdk: oraclejdk7
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.0.6
- jdk: oraclejdk7
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.0-beta-18
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.0-beta-38
- jdk: oraclejdk8
env: TERM=dumb KOTLIN_VERSION=1.0.6
- jdk: oraclejdk8
env: TERM=dumb KOTLIN_VERSION=1.1.0-beta-18
env: TERM=dumb KOTLIN_VERSION=1.1.0-beta-38


env:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.ben-manes.versions' version '0.13.0'
id 'com.github.ben-manes.versions' version '0.14.0'
}

apply from: 'gradle/scripts/tagging.gradle'
Expand Down
2 changes: 1 addition & 1 deletion mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repositories {
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.mockito:mockito-core:2.6.5"
compile "org.mockito:mockito-core:2.7.5"

/* Tests */
testCompile "junit:junit:4.12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ fun <T> OngoingStubbing<T>.doThrow(t: Throwable, vararg ts: Throwable): OngoingS
infix fun <T> OngoingStubbing<T>.doThrow(t: KClass<out Throwable>): OngoingStubbing<T> = thenThrow(t.java)
fun <T> OngoingStubbing<T>.doThrow(t: KClass<out Throwable>, vararg ts: KClass<out Throwable>): OngoingStubbing<T> = thenThrow(t.java, *ts.map { it.java }.toTypedArray())

infix fun <T> OngoingStubbing<T>.doAnswer(answer: (InvocationOnMock) -> T?): OngoingStubbing<T> = thenAnswer(answer)

fun mockingDetails(toInspect: Any): MockingDetails = Mockito.mockingDetails(toInspect)!!
fun never(): VerificationMode = Mockito.never()!!
fun <T : Any> notNull(): T? = Mockito.notNull()
Expand Down
28 changes: 28 additions & 0 deletions mockito-kotlin/src/test/kotlin/test/MockitoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,34 @@ class MockitoTest : TestBase() {
}
}

@Test
fun testMockStubbing_doAnswer() {
/* Given */
val mock = mock<Methods> {
on { stringResult() } doAnswer { "result" }
}

/* When */
val result = mock.stringResult()

/* Then */
expect(result).toBe("result")
}

@Test
fun testMockStubbing_doAnswer_withArgument() {
/* Given */
val mock = mock<Methods> {
on { stringResult(any()) } doAnswer { "${it.arguments[0]}-result" }
}

/* When */
val result = mock.stringResult("argument")

/* Then */
expect(result).toBe("argument-result")
}

@Test
fun mock_withCustomName() {
/* Given */
Expand Down

0 comments on commit 4c7c942

Please sign in to comment.