-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
Non Async Execution causes False Positives #1331
Comments
There does appear to be some settings around it mine are set to warning Im trying to see what the default settings are like but even with a new project and restoring rider settings i can't seem to get a warning. I can't even figure out what setting controls that |
add this to your
|
No matter what i do it doesn't seem to want to pick up that setting from the .editorconfig. that i have at the solution level.
I can still see that setting under Settings > Editor > Inspection Settings > C#. But even setting it to error there does not seem to change anything |
i think you need to raise that one with jetbrains |
I'll checkout why the warnings aren't showing with JetBrains. From what i can tell though it does look like they don't appear with default settings. I had another dev check their Rider setup and had the same problem. I'm not sure "return value of pure method is not used" is the right option, but the "async method without an await" seems better. wouldn't the option you have as an error trigger errors for non-async methods with a return value if it's not used. Some time you don't care about the result. |
for example? |
For example if you wanted to test that creating a User sends an Invite email you might have something like var mockEmailService = new Mock<IEmailService>()
mockEmailService.Setup(mock => mock.SendNewUserEmail());
var userService = new UserService(mockEmailService.Object);
// could normally return a user or id
userService.CreateUser("Name", "[email protected]");
mockSomeClass.Verify(mock => mock.SendNewUserEmail(), Times.Once()); In this case we don't care about the return value of CreateUser. |
is |
Oh i guess not, I didn't know about that attribute. But would that apply to all Async methods or just this one? |
the verify methods are marked with |
and no, i dont think most async members are marked with with |
Describe the bug
Calling
Verifier.Verify
synchronously can cause False Positive test results.Minimal Repro
We recently converted from ApprovalTests and everything was compiling and passing. The Problem though is
Verifier.Verify
is async and it wasn't obvious. So our conversion was calling it synchronously like;It's subtle and causes no Compiler Errors or Failing tests. But the above code Passes with a False Positive if the verified file does not exist or the output does not match. This is because
Verify
should be called async like;We've obviously made a mistake with the conversion by my concern is how do we prevent less experienced dev's reintroducing the same mistake, thinking their snapshot tests are working fine. Perhaps at least naming the method
VerifyAsync
might help.The text was updated successfully, but these errors were encountered: