JohnnyHendriks / TestAdapter_Catch2

Visual Studio Test Adapter for Catch2
MIT License
104 stars 29 forks source link

Question: How do I get the Test Explorer tree to use namespace and class? #41

Closed ebudai closed 4 years ago

ebudai commented 4 years ago

I can't get it to say something other than "< Empty Namespace >" and "< Empty Class >". Googling and reading docs/source finds nothing. I tried to run the ReferenceTests project to get somewhere and got a lot of "cannot find main.cpp" (I can put in another issue for this if you like)

JohnnyHendriks commented 4 years ago

This is just the way Test Explorer works nowadays in VS2019. Use the group by-button in test explorer to change this behavior. Basically the test name is split based into levels using either C++ or C# namespace splitters. See Capabilities documentation for an explanation. I still need to write a walkthrough that makes use of the new VS2019 interface, the current walkthrough uses VS2017.

For the ReferenceTests project you need the full ReferenceTests-folder, and use the appropriate solution in the walkthrough-folder (there is as solution for VS2017 and VS2019). To my knowledge these should work,

IrisPeter commented 2 years ago

Hi @JohnnyHendriks,

I don't think you are right about the above, because although the Google Test runner that comes as part of the possible install for both Visual Studio 2019 and 2022 also has whether there is one or not, with a Google Unit Test the instead of you do actually get the class name showing

image

Is the lack of some parameter within the .runsettings contents. The Google Test runner does not seem to use .runsettings so maybe that's not relevant

JohnnyHendriks commented 2 years ago

Hi @IrisPeter, The Test Explorer appears to be mostly designed around use with .NET languages and test frameworks. But by choosing appropriate test case names we can get a kind of hierarchy of our choosing. When you click the group by button (the one to the left of the button with a plus sign in it), you can configure the levels you want to show. Here Namespace, and Class are elements extracted from the Catch2 TestCase name. E.g., myns.myclass. Test would be split into myns, myclass, and Test elements in a tree. myclass. Test would be split into <Empty Namespace>, myclass, and Test elements in a tree. If you have a lot of tests with the <Empty Namespace> element, you can always deselect the namespace element via the group by button. I have no experience with the Google Test adapter, or Google Tests, so I don't know how this is handled there. See also the Test Explorer docs