Moving MSTEST classes to their own folders breaks "Create unit tests ..."

I like to organize unit test classes in functional areas using folders, just like the process I use to organize application classes.

However, the Create Unit Tests option in the right-click menu for the method breaks if the original target test class moves to a new location, apparently because the code generator is trying to create a new class of the same name in the root of the Unit Tests project.

I can fix the problem temporarily by moving the source test class to the root of the Unit Tests project before doing "Create Unit Tests ..." and then returning it to the original folder when the full code is generated, but this is awkward.

Is there a better way to handle this?

+3
source share
1 answer

This is by design. I use the same strategy as folders to separate my tests, and when I add a new unit test, VS will create a class in the root folder.

So, in the end, I used the code template (in Resharper) that I use to create a new unit test class in the folder. I suggest you do the same - if you are not using Resharper, then you have a piece of Visual Studio code, such as that found here .

+2
source

Source: https://habr.com/ru/post/1781292/


All Articles