0

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);
}

1 Answer 1

3

You can write asynchronous unit tests to test asynchronous methods.

Asynchronous unit tests must be async Task.

Sign up to request clarification or add additional context in comments.

2 Comments

You mean, I have to write two unit test, one for sync method and other one for async method.
If you want to test them both, then yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.