File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
mockito-kotlin/src/test/kotlin/test Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -516,6 +516,41 @@ class MockitoTest : TestBase() {
516
516
expect(result).toBe(" argument-result" )
517
517
}
518
518
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
+
519
554
@Test
520
555
fun mock_withCustomName () {
521
556
/* Given */
You can’t perform that action at this time.
0 commit comments