3

I'm having some issues running OpenCover.console over some .NET assemblies.

We're seeing some MSTEST tests fail, only when run under OpenCover.

What's going on is that we have certain of our tests that are reading and writing to a LocalDB database. Yes, these are more properly called integration tests than unit tests, but they are testing functionality that we need tested.

The tests in question start by clearing the tables that it works with, populating seed data, running some code that should insert records into the database, then reading the database to ensure that the records exist.

What we're seeing is that everything runs correctly, except we're not seeing all of the records that we'd expect.

What we're hypothesizing is that the tests might, when run from OpenCover, be running in parallel, and that the clearing code of one test is running before the testing code of the other test runs.

So, the questions:

  • Does OpenCover run tests in parallel?
  • Is there a way to configure it not to?
  • Better yet - is there a way to configure it not to for some tests but not for others? (Most of our tests don't access the database, and parallelism for them wouldn't be a bad thing.)

The command we're using:

<path>\OpenCover.Console.exe ^
    -target:"<path>\vstestconsole.exe" ^
    -targetargs:"/Logger.trx <listofassemblies>" ^
    -excludebyattribute:*.TestClass*;*.TestMethod*;*.ExcludeFromCoverage* ^
    -output:TestResults\outputCoverage.xml ^
    -filter:"<listoffilters" ^
Jeff Dege
  • 11,190
  • 22
  • 96
  • 165
  • hmm, I'm not to familiar with MSTest, but it seems like you may be a little confused on what open cover is doing. Open Cover isn't running your test, MSTest is. Open cover is just running in the background recording what code is touched as the test is running. I would suggest you look at your mstest settings, i suspect there may be an issue there. Maybe it is setup to run the tests in parallel? – Hack Jan 16 '20 at 14:45

0 Answers0