You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
and a test suite with a buch of almost identical tests.
They should all pass, but only the first one and the last one pass. Others fail as if mock were never called, but it must have been.
importzio.mock.Expectationimportzio.test.Assertion.equalToimportzio.test.{Spec, TestEnvironment, ZIOSpecDefault, assertTrue}
importzio.{Scope, ZIO}
objectMyTraitSpecextendsZIOSpecDefault {
overridedefspec:Spec[TestEnvironment&Scope, Any] =
suite("suite")(
test("test with atMost") {
vallayer=MyTraitMock.MyMethod(assertion = equalTo("arg1"), result =Expectation.value(10)).atMost(1).toLayer
for {
mockInstance <-ZIO.service[MyTrait].provideLayer(layer)
result1 <- mockInstance.myMethod("arg1")
} yield assertTrue(
result1 ==10,
)
},
test("test without quantifier") {
vallayer=MyTraitMock.MyMethod(assertion = equalTo("arg1"), result =Expectation.value(10)).toLayer
for {
mockInstance <-ZIO.service[MyTrait].provideLayer(layer)
result1 <- mockInstance.myMethod("arg1")
} yield assertTrue(
result1 ==10,
)
},
test("test with atLeast") {
vallayer=MyTraitMock.MyMethod(assertion = equalTo("arg1"), result =Expectation.value(10)).atLeast(1).toLayer
for {
mockInstance <-ZIO.service[MyTrait].provideLayer(layer)
result1 <- mockInstance.myMethod("arg1")
} yield assertTrue(
result1 ==10,
)
},
test("test with exactly") {
vallayer=MyTraitMock.MyMethod(assertion = equalTo("arg1"), result =Expectation.value(10)).exactly(2).toLayer
for {
mockInstance <-ZIO.service[MyTrait].provideLayer(layer)
result1 <- mockInstance.myMethod("arg1")
result2 <- mockInstance.myMethod("arg1")
} yield assertTrue(
result1 ==10,
result2 ==10,
)
},
test("test with exactly") {
for {
env <-MyTraitMock.MyMethod(assertion = equalTo("arg1"), result =Expectation.value(10)).exactly(2).toLayer.build
mockInstance = env.get[MyTrait]
result1 <- mockInstance.myMethod("arg1")
result2 <- mockInstance.myMethod("arg1")
} yield assertTrue(
result1 ==10,
result2 ==10,
)
}
)
}
I think there is some issue with expectation count quantifiers when mocks are used as layers.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I use Scala 3.3.3, ZIO 2.1.9, zio-mock: 1.0.0-RC12
Scastie: https://scastie.scala-lang.org/ICPrp4mkQJCBieDRi3gsiA
I have this trait:
a mock for it:
and a test suite with a buch of almost identical tests.
They should all pass, but only the first one and the last one pass. Others fail as if mock were never called, but it must have been.
I think there is some issue with expectation count quantifiers when mocks are used as layers.
The text was updated successfully, but these errors were encountered: