Results Not Available For Classes That Have Only async Methods
If all methods in a class are async, then FCC does not seem to detect the class at all or include coverage information for that class in the output.
If any method of the class is not async, then FCC does detect the class and include coverage in the output, including for any async methods that might be in the class.
For example, FCC does not seem to properly report coverage when testing the following class:
public class AsyncCalc {
public static async Task<int> Add(int a, int b)
{
return a + b;
}
public static async Task<int> Subtract(int a, int b)
{
return a - b;
}
}
Albeit from a fork of FCC
Have you turned off showing coverage when a class is fully covered ?
HideFullyCovered | Set to true to hide classes, namespaces and assemblies that are fully covered.
( just in case ) Hide0Coverage | Set to true to hide classes, namespaces and assemblies that have 0% coverage.
Hm, that's definitely not what I'm seeing.
I have both of those settings set to false.
Then the sut assembly has likely not been included or the class itself has been excluded.
In the assembly with the class with only async methods are you receiving coverage for other classes ?
If you are using the option MsCodeCoverage - Yes and have not provided your own runsettings then you can check the generated .runsettings file within a sub directory of your test project's bin/Debug/../fine-code-coverage/coverage-tool-output If not MsCodeCoverage then the FCC output window pane shows the command line arguments used to run the coverage.
You should check the FCC output window pane regardles.
If this is not sufficient for you to determine why you have no coverage then you need to provide a minimal reproducible solution that exhibits this behaviour and provide the FCC visual studio options that you have set.
Note that IncludeReferencedProjects is not transitive.
You need the pdb for the assembly you want covered. Are you running tests in debug or release ?
Thanks for the assistance. Your project does not compile for me without changing the signature of WhenAllAsync to
public async Task WhenAllAsync()
After making that change, I am seeing the same behavior with your project.
Here is the project where I am producing this. I have two classes in the assembly under test, one that uses async methods and one that uses sync methods. The async class has source code showing as "not included' while the sync class is showing coverage as expected. FCCBug.zip
Here is my FCC output including the generated runsettings file (note that I have redacted system path and user information):
Here are my VS settings as screenshots (please let me know if there is a better way to export settings):
Perhaps this is the issue - from the readme
The old coverage was based upon every test. Ms code coverage is coverage from the tests you select in the test explorer.
I am seeing this behavior even when asking the Test Explorer to run all tests.
I am out so will have a look later.
Can you screenshot the report and the editor colouring
Here is the coverage report:
Here is the AsyncCalc class:
Here is the Calc class (Add is sync, Subtract is still async but is correctly showing as covered):
"I am seeing this behavior even when asking the Test Explorer to run all tests."
The AsyncTest class tests are not being run.
As you are using Microsoft.VisualStudio.TestTools.UnitTesting
My apologies, the access level of AsyncCalc should be public and not internal. However, if I change AsyncCalc to public from internal, the tests run:
But I am still not seeing code coverage:
Here is the corrected solution:
I think the issue is with report generator not understanding the cobertura report that is generated from microsoft code coverage. Report generator is used for resolving names and producing the final cobertura report that FCC uses. Unfortunately with the version of report generator that FCC is currently using ( which cannot be changed easily as we are embedding their HTML report which is no longer supported in WebBroswer form ) this is indeed an issue and I apologize for being flippant before.
As a workaround you can set RunMsCodeCoverage No.
A better report that is up to date with report generator will be available soon.
https://github.com/danielpalme/ReportGenerator/releases/tag/v5.3.5
Wonderful, thanks for the help and glad to hear a fix is on the way!