Test Explorer does not group by Test Herarichy / Namespace using NUnit in VS 2017

826 Views Asked by At

i have been using NUnit with Visual Studio 2017 and its working fine until my test cases grouped wrongly in test explorer

enter image description here

i have Code herarichy like Project Name > Component.PDF.Tests Classes Name > PDFDOcument Classes Name > FormField Classes Name > Attachment

i have created all test methods under different classes but when i group by name space or test herarichy, i was expecting it will be grouped under Class name but above image shows most of the test cases comes under project name

Some of the test comes under Clases but all others moved to Parent namespace even though all of the classes and their tests defined in same way

  • Envrioment: VS 2017
  • Test Framework : NUnit 3.0
  • Test Adapter : NUnit Adapter

has any one face this issue ? or i misunderstood something any help will be appreciated

1

There are 1 best solutions below

4
Terje Sandstrøm On

By default, VS groups Project, Namespace, Class - and then the test methods, as shown in the image below: enter image description here

You can change this whatever way you want, by editing the grouping. The default grouping will look like shown below.
enter image description here

So if you want just to group by class name, remove the others.

This is with VS 2019. With VS 2017 you have something they call Show Test Hierarchy, and it is defined to work the same way, Project - Namespace - Class and then the test methods.

If you disable that one (1 - below), you can change the Group by to only show "by class" (2-below).

enter image description here

and you end up with: enter image description here