Change Default MsTest Unit Test Wizard Template

旧时模样 提交于 2019-11-28 10:26:43

Yes, you can, on several levels:

Project Template

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

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.

Unit Test File Template

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

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

  • SimpleUnitTest.cs
  • SimpleUnitTest.vstemplate

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.

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

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

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.

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