0

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

Salman
  • 1,266
  • 5
  • 21
  • 41
  • I believe you need to explain a bit more about **what** is wrong, make it more explicit. Boil it down to something simple to explain, and show images of that, and even some code snippets for what is being shown. Also, ensure you run the latest versions of VS and NUnit/Adapter, there are changes in them all. – Terje Sandstrøm Nov 21 '19 at 09:25
  • @TerjeSandstrøm i m using latest version of NUnit and Nunit Adapter regarding what is wrong. i m getting 37 test cases under Components.PDF.Tests where as these 37 tests are defined under PDFDocumentFIxture or other classes that marked as Text Fixture . This issue m compalining is about why test comes under project name rather than under class name – Salman Nov 22 '19 at 14:34

1 Answers1

0

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

Terje Sandstrøm
  • 1,979
  • 15
  • 14
  • i have already tried that but it didnot worked , only difference in your example and mine is that i m using test data that that can be 1 or multiple . May be thats causing the issue :( – Salman Nov 23 '19 at 19:55
  • Can you add some code fractions to repro your situation ? – Terje Sandstrøm Nov 23 '19 at 21:28
  • Images will work or you want working code repo to reproduce the issue – Salman Nov 27 '19 at 10:20
  • ok i will get it for you , just a side note i have instsalled AxoCover extension and it showed all test cases as expected in its viewer. – Salman Dec 05 '19 at 10:50