Skip to content

Commit

Permalink
added regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
pawel bochenski committed Apr 1, 2017
1 parent 5a5fa35 commit 3349ebd
Showing 1 changed file with 35 additions and 0 deletions.
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 3349ebd

Please sign in to comment.