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
Please describe the expected behavior of the issue
The examples on https://scalamock.org/user-guide/sharing-specs2/ make it look like writing expectations inside a specs2 Specification should work without further boiler-plate as long as the test is wrapped in a in new MockContext {}.
Please provide a description of what actually happens
However, I find that the expectation is ignored if it's not wrapped in a withExpectations call.
I'm not sure if the problem is the documentation - the withExpectations boiler-plate needs to be there, or the code itself - withExpectations should be called under the hood somehow but isn't.
Reproducible Test Case
importorg.scalamock.specs2.MockContextimportorg.specs2.mutable.SpecificationclassMockTestextendsSpecification {
classTestable() {
defret():Int=2
}
"expectation" should {
"fail" in newMockContext {
valm= mock[Testable]
// this should fail IMO but it doesn't.// if I wrap it in `withExpectations`, however, it fails when // using `once()` and works when using `never()` - as expected
(m.ret _).expects().returns(1).once()
}
}
}
The text was updated successfully, but these errors were encountered:
ScalaMock Version (e.g. 3.5.0)
5.2.0
(specs2: 4.20.2)
Scala Version (e.g. 2.12)
2.13
Runtime (JVM or JS)
JVM
Please describe the expected behavior of the issue
The examples on https://scalamock.org/user-guide/sharing-specs2/ make it look like writing expectations inside a specs2 Specification should work without further boiler-plate as long as the test is wrapped in a
in new MockContext {}
.Please provide a description of what actually happens
However, I find that the expectation is ignored if it's not wrapped in a
withExpectations
call.I'm not sure if the problem is the documentation - the
withExpectations
boiler-plate needs to be there, or the code itself -withExpectations
should be called under the hood somehow but isn't.Reproducible Test Case
The text was updated successfully, but these errors were encountered: