0
votes

I have structured my Tests in Visual Studio like so:

[TestClass]
public class TestContainer
{

    [TestClass]
    public class MoreSpecificContainer
    {

        [TestMethod]
        public void Test_Should_ReturnSomething()
        {

        }
   }


    [TestClass]
    public class AnotherSpecificContainer
    {

        [TestMethod]
        public void AnotherTest_Should_ReturnSomething()
        {

        }
   }
}

Sadly, OpenCover (great tool, btw!) is not including the nested TestClass methods in it's coverage. I assume this is because they're nested. If I remove the nested 'MoreSpecificContainer' and 'AnotherSpecificContainer' classes and the test methods are only inside the main 'TestContainer' TestClass, then the tests are run by OpenCover and results are included in the reporting perfectly. Using OpenCover 4.6.166 and ReportGenerator.2.3.2.0

Is there any way that anybody knows of to configure OpenCover to notice the methods inside nested TestClasses?

Thank you, codenewbie

1
Through more trial and error, I removed the [TestClass] from the nested test classes, and found that OpenCover will provide info for the tests. I lose the grouping in VS, but this may be a compromise I have to live with. If anybody knows any way to have the best of both worlds, please let me know.codenewbie

1 Answers

0
votes

OpenCover doesn't run your tests, the application you use for target does.

Try running your tests on the command line without OpenCover and review your results.