'TestCleanup cannot be async?
As far as I understand testcleanup can't be async for example (for example here https://social.msdn.microsoft.com/Forums/vstudio/en-US/3a23bd9d-7a5a-490e-a199-b8dfa309f39e/unittesting-problem-with-async-testinitialize-method?forum=vstest)
But i didn't found anything in official documentation(https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testcleanupattribute.aspx) also it does compiled in VS successfully.
I have two questions:
- Could someone explain to me why?
- Is there any official documentation about it?
Solution 1:[1]
TestCleanup still cannot be async.
If you're looking for a code example try this:
[TestCleanup]
public void TestCleanup()
{
Task Action() => MyAsyncMethod(myparams);
Task.Run(Action);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | crthompson |
