-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.3.1 breaks tests that worked before #197
Comments
@threema-donat can you share some of the breaking tests or some minimal code to reproduce this? did you manage to fix the tests for 1.3.1 and if so, what did you have to do? could this be related to calling the sync methods from within an async runtime (which was never supported - see the async section inside the docs)? |
+1, our async tests broke after updating mockito v1.1.0 -> v1.4.0.
I'm glad they broke, but may I nonetheless suggest detecting this (if at all possible) and printing a more useful error message (pointing to the docs)? |
@punkeel I assume the reason was using the sync methods instead of the async ones inside async tests, right? This is one of the reasons I mention the error in the docs (though I think it's a slightly different version). I could add the other error message to the docs as well. Not sure if there's any other (easy) way to hint users about this. This is I guess one of the downsides of supporting both a sync and an async interface but I don't intend to change that any time soon. |
Yep, exactly that |
It looks like it's possible (and easy) to tell if a function is called in the context of a Tokio runtime: tokio::runtime::Handle::try_current()
.expect_err("mockito error: use async methods when running inside Tokio - .... link to docs"); Would it make sense to detect this scenario and print a custom message guiding users to the docs? |
Sorry for the late reply; It was also due to this mistake that our tests broke. A custom message would certainly make the update to the latest version easier. I would have expected the minor version to be increased if this worked before and not anymore in version '1.3.1'. Also, a note could have been added to the version to make the migration easier for people who mistakenly called the sync methods. Thanks a lot for your work! |
Hey there!
I recently updated the dependencies of a crate via
cargo audit
, which broke all the tests where we used tokio as runtime and mockito for mocking a http server because of starting a runtime from within a runtime.I concluded that the version
1.3.1
of mockito should actually have been a breaking release.The text was updated successfully, but these errors were encountered: