-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code coverage drops after updating xunit.runner.visualstudio to v2.5.0 #381
Comments
The only changed we've made regarding code coverage was to ensure that the test adapter wasn't included in the coverage result: 86c0e57 That should not impact your code at all. How are you collecting coverage? Can you provide a repro project? |
We have detected the same problem in two different applications. In both cases there are projects that have no tests and some of them are being excluded from the coverage calculation. We run the tests and generate the code coverage reports in Azure DevOps. These are the tasks:
|
@ValMati This is still not enough information. Please provide a complete project that illustrates the issue. |
The Emby.Naming project in the jellyfin solution has this problem I use this command to get code coverage for the whole solution Historic coverage can be seen here: https://cov.b0n.dev/jellyfin/ |
I'm sorry, but the project where I detected the bug is private, from the company I work for, and I can't share it. I have tried to reproduce the bug in an solution as simple as possible, but I have not been able to. It seems that the problem appears with a specific combination of "variables". |
I have narrowed down the problem to fixing this issue: #317 The real world implication here is that we used to load every assembly in your test assembly's folder into memory to look for test runner reporters, whereas now we do not (we only load those that have a name matching The implication is that some of your tests were previously unintentionally dependent on this behavior of pre-loading all assemblies. A quick search of your source I see two instances of public static TheoryData<Type> BaseItemKind_TestData()
{
var data = new TheoryData<Type>();
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in loadedAssemblies)
{
if (IsProjectAssemblyName(assembly.FullName))
{
var baseItemTypes = assembly.GetTypes()
.Where(targetType => targetType.IsClass
&& !targetType.IsAbstract
&& targetType.IsSubclassOf(typeof(MediaBrowser.Controller.Entities.BaseItem)));
foreach (var baseItemType in baseItemTypes)
{
data.Add(baseItemType);
}
}
}
return data;
} I believe this is probably the source of the coverage drop issue. (There is a second instance in |
@ValMati There is an easy way to test if this is your problem: if you have normal code coverage with |
I've run the tests with those versions and the result is as you predicted. With version |
I am sorry, but I disagree with the closure of this issue. I think the change in behaviour can be considered a regression as it changes the outcome without changing the inputs. Moreover, the coverage it gives now is not correct as there are projects that are not accounted for. |
@ValMati The bug is in your code, not in our code. You were unintentionally depending on behavior that's not longer true. The only way for me to "fix" this would be to revert back to our previous behavior which had performance problems. You're going to have to fix your code instead. Sorry. |
After updating xunit.runner.visualstudio our code coverage dropped significantly. Looking at the classes where coverage dropped it shows 2 files one locally and one on GitHub. Based on this I'm assuming that xunit.runner.visualstudio v2.5.0 somehow includes links from Microsoft.SourceLink.GitHub as source files.
Example: https://cov.b0n.dev/jellyfin/Emby.Naming_AlbumParser.html
The text was updated successfully, but these errors were encountered: