Closed soujiro32167 closed 1 year ago
Looks like this happens when the input includes a ZStream
Actually, this is not even about streams. This error happens when ANY expectation is unmet 😱
I just encountered this issue 😵💫
Hey - I just rewrote a whole app to ZIO 2 and that was the hardest part. There is a way to get the reporting: use sut.exit
to get details about the exception. It is far from ideal, but it works.
I have not looked into the code, but if given proper indications of where to look, I am happy to try and submit a fix for this.
Hi @regiskuckaertz!
This is broken because of https://github.com/zio/zio-mock/issues/22 - it was a compromise as I did not have time to look into this but wanted to have a somewhat working version so other libraries like zio-aws can move forward in the migration process.
If you could help fixing it it would be really appreciated!
Some info:
MockReporterSpec
and now they are ignore
d. So I would start by reenabling those tests.MockReporter
object, not properly catching and/or rendering these exceptions@vigoo ok thanks for that! I'm going to go through each error at a time and the first easy one is this expectation:
✖ Expected a call to zio.mock.MockConsole.Print(equalTo(foo)), but zio.mock.MockConsole.PrintLine was invoked instead. (HINT: Remember order is important when considering mock invocations.)
is not met because the assertion is rendered like so:
private def renderAssertion(ass: Assertion[_]): String = bold(magenta(ass.toString()))
which uses the stock Java toString
. The result is this:
✖ Expected a call to zio.mock.MockConsole.Print(Assertion(Meta(TestArrowF(zio.test.TestArrow$$$Lambda$39685/0x0000000803b93020@66a2c17f),None,None,Some(equalTo),None,None,None,None))), but zio.mock.MockConsole.PrintLine was invoked instead. (HINT: Remember order is important when considering mock invocations.)
Is there an assertion renderer provided by zio-test?
@swoogles Hi 👋 Sorry to pull you in, just wondering if you could point me to the right way of rendering an assertion here. I found ConsoleRenderer
and something that looks useful maybe (renderRuntimeCause
) but the output is a ExecutionResult
and it is not clear how to plug the mock-specific error messages into it, or how to turn it into a string. Also the MockReporter
only handles TestFailure.Runtime
, should it also process TestFailure.Assertion
?
Hey @regiskuckaertz , I'm on holiday this week but will take a look on Sunday or Monday!
@swoogles happy thanksgiving!
What is the state on this? Could I potentially contribute?
+1 to above - it's really painful now if you have to deal with failing more complex tests... Any chance to have a fix for this pushed forward?
Hey! I managed to update zio-mock into failing with something like this:
- MockReporterSpec - Behavior - fail?
Exception in thread "zio-fiber-471" zio.mock.internal.MockException$InvalidCallException: equalTo(zio.stream.ZStream@7bc5ab8a)
at zio.mock.internal.ProxyFactory$$anon$1.$anonfun$invoke$37(ProxyFactory.scala:374)
at zio.ZIO$.$anonfun$die$1(ZIO.scala:3095)
at zio.ZIO$.$anonfun$failCause$1(ZIO.scala:3166)
at zio.mock.MockReporterSpec.behaviorSuite(MockReporterSpec.scala:156)
at zio.mock.MockReporterSpec.behaviorSuite(MockReporterSpec.scala:153)
at zio.mock.MockReporterSpec.behaviorSuite(MockReporterSpec.scala:151)
Using the repro code in the original issue - would this be good enough to contribute? Or would you like to fix it into something better / more descriptive?
Hi, is there any chance to have a mocked method info as well - so in this case CreateDocument
?
MockReporter
aspect (@@ MockReporter()
) or the spec extends MockSpecDefault
(which does the former automatically)Hi, any progress on this?
I have similar error, using example from docs:
and it fails with:
Is there any solution for that?
So it seems real Random is called, not the MockRandom
@adamgfraser are you aware about this issue? actually even tests in this project fail, any chance you can advise here?
Just tested with the latest snapshot and that doesn't seem to happen anymore. Any chance we could get a new release @adamgfraser @vigoo ? 🙇♂️
@regiskuckaertz Sure!
I've updated the scastie to latest ZIO and zio-mocks, but still getting the same behavior =[ https://scastie.scala-lang.org/soujiro32167/p6PBZRuGQwa7vXrmToKt8w/11
I've updated the scastie to latest ZIO and zio-mocks, but still getting the same behavior =[ https://scastie.scala-lang.org/soujiro32167/p6PBZRuGQwa7vXrmToKt8w/11
As mentioned above, you have to extend MockSpecDefault
instead of ZIOSpecDefault
. Your example works otherwise.
Totally missed that! Thanks @SirStoke
When running mocks with ZIO 2.0.2 and zio-mock 1.0.0-RC9, I get the following exception:
To reproduce:
Scastie: https://scastie.scala-lang.org/soujiro32167/p6PBZRuGQwa7vXrmToKt8w/7