Reputation: 5
I just need information about code coverage of webservice method that includes Async Methods as well.
Suppose, I have one method written in WebService, MethodOne(string Value)
and I have written TestMethod
to check code coverage for this method,
When I run Test and check in code coverage, it showing me something like
MethodOne(string)
100%
MethodOneAsync(string)
0%
MethodOneAsync(string,object)
0%
so because of Asynchronous methods, I can not verify the actual code coverage of my projects, I want to cover these kind of methods as well in my code coverage.
I researched on google and read many articles but didn't get a valuable code, I have written following code as well but it doesn't help as well.
public async void TestMethod1Async()
{
bool isValue = await System.Threading.Tasks.TaskEx.Run(() => target.IsAccountDisabled(Guid.NewGuid()));
Assert.IsFalse(isValue);
}
Upvotes: 0
Views: 312
Reputation: 456342
You can write asynchronous unit tests to test asynchronous methods.
Asynchronous unit tests must be async Task
.
Upvotes: 3