coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.97k stars 386 forks source link

TestCase ignored in coverage #1446

Closed creasoft-dag closed 1 year ago

creasoft-dag commented 1 year ago

Hi,

when i only use [TestCase] attributes then the tests are ignored in the coverage. If i add [Test] attributes the coverage is working as expected.

    [Test]
    [TestCase("de")]
    [TestCase("en")]
    [TestCase("xy")]
    [TestCase(null)]
    public async Task MyTest(string language)
    {
      // Arrange
      ...

      // Act
      ...

      // Assert
      using (new AssertionScope())
      {
        ...
      }
    }

Best regards, Daniel

creasoft-dag commented 1 year ago

Update: [Test] Attribute only worked für dotCover (which we use local) but not for coverlet (which runs on our CI server). So all the [TestCase] tests are ignored in our coverlet analysis.

daveMueller commented 1 year ago

Could you elaborate this a bit more or even better would be small repro so we can exactly see what the issue is. The instrumentation for the coverage is done on the assembly under test and not the test assembly itself, thus I don't really see how the [Test] attribute should have any influence on this. Or do you want the test assembly to be included in the coverage report? Therefore coverlet has a setting IncludeTestAssembly which is also discussed here #618.

creasoft-dag commented 1 year ago

nvm I just forgot to add the coverlet dependency for some projects - thanks for your help