How do I cover async methods while not performing await in unit test code.


I am using dotCover 3.2. Build 103.0.20150819.154242 packaged with TeamCity Professional 9.1.3 (build 37176)

My unit tests are written in vstest.console tooling.

I have written a test that results in a ViewModel executing code that is marked with the async keyword.

I execute it by performing a spinwait on a flag.

I know the code executes from debugging and logging.

I know async creates a state machine.

I thought dotCover was smart enough to piece together the coverage.

Is it not?

Do I have to return to coverage tool evaluation?

Do I have to re-write my test for dotCover to realize its coverage?

Thank you for your time.

-Christopher Buteau

1 comment
Comment actions Permalink

I figured it out...
I had excluded System.Runtime.CompilerServices.CompilerGeneratedAttribute to exclude the tool generated classes for Resource files.

But this attribute is also tagged on the async state machine classes that are generated by the compiler.


Please sign in to leave a comment.