Search code examples
c#visual-studiounit-testingnunitnunit-3.0

Different number of tests in Test Explorer and Test Output Window


I have noticed this in several projects and it finally got me curious enough to ask this to you all!

When developing a project in Visual Studio, there always comes a time when I notice Visual Studio's Test Explorer tells me there are fewer Tests than stated in the Test Output Window.

VS Screenshot showing the issue

I am using NUnit 3 with the NUnit3 Test Adapter in Visual Studio, all Versions are up to date. And I have no clue how this could be caused.

So my Questions are:

  • What is causing this?
  • Can it be prevented?
  • Who is right/which number of tests is acually correct?

Solution

  • The most common reason for the discrepancy is that some tests have the same name, from the point of view of VS. In that case, two or more nunit tests may count as one vs test with multiple results. If you have the patience, you can select tests one by one and see how many display multiple results.

    There can be other reasons as well. It would require examination of your actual tests, one by one, in order to give a precise answer. As a basis for comparison, consider running the tests under either the NUnit console runner or the TestCentric GUI.