-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Problem:
Let's say we have two different service
class ServiceA(serviceB: ServiceB) {
def methodA(): String = {
"methodA called"
serviceB.methodB()
}
def methodA2(): String = {
"methodA2 called"
serviceB.methodB()
}
}
I write two test method and try to verify methodB called or not. When I run two test cases separately, tests pass. When I run all test methods, verification gives wrong result for second test.
In test class context, mockito-verification records all calls on mock object. I think mockito-scala should reset verification counts on mock objects after each test
class ServiceATest extends FlatSpec with IdiomaticMockito {
val serviceB: ServiceB = mock[ServiceB]
val serviceA: ServiceA = new ServiceA(serviceB)
"methodA" should "called" in {
serviceA.methodA()
serviceB.methodB wasCalled once // Passes
}
"methodA2" should "called" in {
serviceA.methodA2()
serviceB.methodB wasCalled once // Fail. it was 2 times:
}
}
Btw I tried with mockito-core, it gives same error.
Metadata
Metadata
Assignees
Labels
No labels