Moving MSTEST classes into their own folders breaks “Create Unit Tests…”

岁酱吖の 提交于 2019-12-06 06:38:13

问题


I like to organize my unit test classes into functional areas using folders, much like the process I use to organize my application classes.

However, the "Create Unit Tests" option in the right-click menu for a method breaks if the original target test class is moved to a new location, presumably 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 original test class into the root of the Unit Tests project, prior to executing "Create Unit Tests...", and then move it back into its original folder when the code generation is complete, but this is clumsy.

Is there a better way to manage this?


回答1:


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

So, I ended up using a code template (in Resharper) that I use to create a new unit test class in a folder. I suggest you do the same - if you don't use Resharper then have a Visual Studio code snippet like the ones found here.



来源:https://stackoverflow.com/questions/4492662/moving-mstest-classes-into-their-own-folders-breaks-create-unit-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!