Skip to content

Commit

Permalink
Merge pull request #160 from nhaarman/release-1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
nhaarman committed Apr 1, 2017
2 parents 4c7c942 + 8a8a727 commit e0c1475
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ language: java
matrix:
include:
- jdk: oraclejdk7
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.0.6
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.0.7
- jdk: oraclejdk7
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.0-beta-38
env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1.1
- jdk: oraclejdk8
env: TERM=dumb KOTLIN_VERSION=1.0.6
env: TERM=dumb KOTLIN_VERSION=1.0.7
- jdk: oraclejdk8
env: TERM=dumb KOTLIN_VERSION=1.1.0-beta-38
env: TERM=dumb KOTLIN_VERSION=1.1.1


env:
Expand Down
4 changes: 2 additions & 2 deletions mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply from: './publishing.gradle'
apply plugin: 'org.jetbrains.dokka'

buildscript {
ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.0.6'
ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.0.7'

repositories {
mavenCentral()
Expand All @@ -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.7.5"
compile "org.mockito:mockito-core:2.7.21"

/* Tests */
testCompile "junit:junit:4.12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ inline fun <reified T : Any> mock(
KStubbing(this).stubbing(this)
}!!

inline fun <T : Any> T.stub(stubbing: KStubbing<T>.(T) -> Unit) = this.apply { KStubbing(this).stubbing(this) }

@Deprecated("Use mock() with optional arguments instead.", ReplaceWith("mock<T>(defaultAnswer = a)"), level = WARNING)
inline fun <reified T : Any> mock(a: Answer<Any>): T = mock(defaultAnswer = a)

Expand Down
35 changes: 35 additions & 0 deletions mockito-kotlin/src/test/kotlin/test/MockitoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,41 @@ class MockitoTest : TestBase() {
expect(result).toBe("argument-result")
}

@Test
fun testMockStubbingAfterCreatingMock() {
val mock = mock<Methods>()

//create stub after creation of mock
mock.stub {
on { stringResult() } doReturn "result"
}

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

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

@Test
fun testOverrideDefaultStub() {
/* Given mock with stub */
val mock = mock<Methods> {
on { stringResult() } doReturn "result1"
}

/* override stub */
mock.stub {
on { stringResult() } doReturn "result2"
}

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

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

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

0 comments on commit e0c1475

Please sign in to comment.