将MSTEST类移动到其自己的文件夹中会中断“创建单元测试...". [英] Moving MSTEST classes into their own folders breaks "Create Unit Tests..."

查看:83
本文介绍了将MSTEST类移动到其自己的文件夹中会中断“创建单元测试...".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢使用文件夹将单元测试类组织到功能区域中,就像我用来组织应用程序类的过程一样.

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?

推荐答案

这是设计使然.我使用相同的策略,即使用文件夹拆分测试,然后添加新的单元测试时,VS会在根文件夹中创建该类.

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.

因此,我最终使用了代码模板(在Resharper中),该模板用于在文件夹中创建新的单元测试类.我建议您做同样的事情-如果您不使用Resharper,则应像找到

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.

这篇关于将MSTEST类移动到其自己的文件夹中会中断“创建单元测试...".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆