-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Asynchronous test methods rejected unless they use the async keyword #500
Comments
Thank you for your feedback. |
@spanglerco , I see no specific reason for methods returning Task to be defined as asyn, if they are not doing any async work inside. Can you please raise PR for this. /cc @jayaranigarg |
@AbhitejJohn any particular reason why we do not run methods which have return type |
@mayankbansal018 : This is probably an artifact of the past. I do not see any reason why that should still be the case but please make sure that any documentation is updated as well. |
Description
I have a test method that returns a Task. This works when the method also uses the async keyword, but removing the async keyword results in UTA007: Method does not have correct signature. This appears to be intentional based on the IsValidTestMethodShouldReturnFalseForMethodsWithNonVoidReturnType test, but I'm wondering why the caller should care if the method is implemented via async state machine or not.
If it's not intentional, I have a potential fix in my fork that I can create a PR for.
Steps to reproduce
Expected behavior
MyTests.MyTest is discovered as a test to run.
Actual behavior
UTA007: Method MyTest defined in class MyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
Environment
MSTest 1.3.2
The text was updated successfully, but these errors were encountered: