Skip to content

Commit 4a5716c

Browse files
committed
Verify we can now create mocks while stubbing existent ones
1 parent 9fb8a57 commit 4a5716c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/src/test/scala/org/mockito/MockitoSugarTest.scala

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class MockitoSugarTest
2020
def iStartWithByNameArgs(byName: => String, normal: String): String = s"$normal - $byName"
2121

2222
def iHaveFunction0Args(normal: String, f0: () => String): String = s"$normal - $f0"
23+
24+
def returnBar: Bar = ???
2325
}
2426

2527
class Bar {
@@ -42,6 +44,14 @@ class MockitoSugarTest
4244
aMock.bar shouldBe "mocked!"
4345
}
4446

47+
"create a mock while stubbing another" in {
48+
val aMock = mock[Foo]
49+
50+
when(aMock.returnBar) thenReturn mock[Bar]
51+
52+
aMock.returnBar shouldBe a[Bar]
53+
}
54+
4555
"default answer should deal with default arguments" in {
4656
val aMock = mock[Foo]
4757

0 commit comments

Comments
 (0)