Skip to content

Commit e0c1475

Browse files
authored
Merge pull request #160 from nhaarman/release-1.4.0
Release 1.4.0
2 parents 4c7c942 + 8a8a727 commit e0c1475

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ language: java
55
matrix:
66
include:
77
- jdk: oraclejdk7
8-
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.0.6
8+
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.0.7
99
- jdk: oraclejdk7
10-
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.0-beta-38
10+
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.1
1111
- jdk: oraclejdk8
12-
env: TERM=dumb KOTLIN_VERSION=1.0.6
12+
env: TERM=dumb KOTLIN_VERSION=1.0.7
1313
- jdk: oraclejdk8
14-
env: TERM=dumb KOTLIN_VERSION=1.1.0-beta-38
14+
env: TERM=dumb KOTLIN_VERSION=1.1.1
1515

1616

1717
env:

mockito-kotlin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply from: './publishing.gradle'
33
apply plugin: 'org.jetbrains.dokka'
44

55
buildscript {
6-
ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.0.6'
6+
ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.0.7'
77

88
repositories {
99
mavenCentral()
@@ -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.7.5"
31+
compile "org.mockito:mockito-core:2.7.21"
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
@@ -175,6 +175,8 @@ inline fun <reified T : Any> mock(
175175
KStubbing(this).stubbing(this)
176176
}!!
177177

178+
inline fun <T : Any> T.stub(stubbing: KStubbing<T>.(T) -> Unit) = this.apply { KStubbing(this).stubbing(this) }
179+
178180
@Deprecated("Use mock() with optional arguments instead.", ReplaceWith("mock<T>(defaultAnswer = a)"), level = WARNING)
179181
inline fun <reified T : Any> mock(a: Answer<Any>): T = mock(defaultAnswer = a)
180182

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,41 @@ class MockitoTest : TestBase() {
516516
expect(result).toBe("argument-result")
517517
}
518518

519+
@Test
520+
fun testMockStubbingAfterCreatingMock() {
521+
val mock = mock<Methods>()
522+
523+
//create stub after creation of mock
524+
mock.stub {
525+
on { stringResult() } doReturn "result"
526+
}
527+
528+
/* When */
529+
val result = mock.stringResult()
530+
531+
/* Then */
532+
expect(result).toBe("result")
533+
}
534+
535+
@Test
536+
fun testOverrideDefaultStub() {
537+
/* Given mock with stub */
538+
val mock = mock<Methods> {
539+
on { stringResult() } doReturn "result1"
540+
}
541+
542+
/* override stub */
543+
mock.stub {
544+
on { stringResult() } doReturn "result2"
545+
}
546+
547+
/* When */
548+
val result = mock.stringResult()
549+
550+
/* Then */
551+
expect(result).toBe("result2")
552+
}
553+
519554
@Test
520555
fun mock_withCustomName() {
521556
/* Given */

0 commit comments

Comments
 (0)