更改默认的MsTest单元测试向导模板 [英] Change Default MsTest Unit Test Wizard Template

查看:107
本文介绍了更改默认的MsTest单元测试向导模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在使用单元测试向导,但发现烦人的杂物数量.反正有没有修改此模板?

My team is using the unit test wizard, but has found the amount of cruft generated annoying. Is there anyway to modify this template?

谢谢

推荐答案

是的,可以在几个级别上进行:

Yes, you can, on several levels:

项目模板

您可以使用Visual Studio中的选项"菜单来摆脱关于测试项目"和其他文件.

You can get rid of the "About Test Projects" and other files using the Options menu in Visual Studio.

转到测试工具"->测试项目",然后取消选择不需要的选项.

Go to Test Tools -> Test Project and unselect the options you don't want.

如果这还不够,您可以在类似于以下的文件夹中找到项目模板:

If that is not enough, you can find the project template in a folder similar to this:

C:\ Program Files(x86)\ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ProjectTemplates \ CSharp \ Test \ 1033

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Test\1033

如果您在32位Windows上运行或具有不同的区域性,则您的路径可能会略有不同,但是您应该可以找到它.

Your path may differ slightly if you run on 32-bit Windows or have a different culture, but you should be able to find it.

单元测试文件模板

在Vanilla Visual Studio中,可以在与此类似的文件夹(从我的机器中)中找到单元测试的模板:

In vanilla Visual Studio, the templates for the unit test can be found in a folder similar to this (from my machine):

C:\ Program Files(x86)\ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ItemTemplates \ CSharp \ 1033

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\1033

在此文件夹中,有一个名为SimpleUnitTest.zip的文件,其中包含两个文件:

In this folder there is a file called SimpleUnitTest.zip that contains two files:

  • SimpleUnitTest.cs
  • SimpleUnitTest.vstemplate

您可以编辑SimpleUnitTest.cs文件以删除所有不需要的代码,但是您必须记住重新压缩文件,以便包含您的更改.

You can edit the SimpleUnitTest.cs file to remove all the code you don't want to have, but you must remember to re-zip the file so that it contains your changes.

但是,如果仅 这样做,则VS可能不会很快接受您的更改,因为VS会在其中维护模板的未压缩缓存.

However, if you only do that, VS may not pick up your changes anytime soon, since it maintains an unzipped cache of templates in

C:\ Program Files(x86)\ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ItemTemplatesCache \ CSharp \ 1033

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\CSharp\1033

因此,您还需要在此编辑文件(或简单地将已更改的文件复制到此处).

So you will need to edit the file there as well (or simply copy your changed file there).

据我所知,VS通常使用ItemTemplateCache中的模板,但偶尔会从ItemTemplates中恢复它们.应用更新时似乎会发生这种情况,但是我还没有找到一个一致的模式,因此简单地在两个地方进行更新是修改我能够提出的模板的最佳方法.

As far as I have been able to tell, VS normally uses the templates in ItemTemplateCache, but occasionally reinstates them from ItemTemplates. This seems to happen when updates are applied, but I have yet to identify a consistent pattern, so simply updating in both places is the best way to modify the templates that I have been able to come up with.

这篇关于更改默认的MsTest单元测试向导模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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