我通过当我在Visual Studio中新的单元测试时使用的不必要的详细模板日益恼火(使用默认,包括单元测试框架)。代替

public ImportModelStateTest()
{
    //
    // TODO: Add constructor logic here
    //
}

private TestContext testContextInstance;

/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
    get
    {
        return testContextInstance;
    }
    set
    {
        testContextInstance = value;
    }
}

我想有简单地

/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext { get; set; }

如果我需要一个构造函数,我将添加一个,同样也适用于特殊的getter和setter。我也想删除所包含的样本TestMethod的 - 我还需要重新命名它,这样我就可以和写我自己从头

我已经找了用于创建这些测试文件的模板,但没能找到它(我的用于控制器和视图的T4模板附近看了大多是围绕)。我在哪里可以改变这个模板?

有帮助吗?

解决方案

所有的视觉工作室的项目模板从这个目录中运行:

  

C:\ Program Files文件\微软的Visual Studio 9.0 \ Common7 \ IDE \的ItemTemplate

当然的C:\ Program Files文件可能会根据您的安装选项更改。我认为测试模板位置为:

  

C:\ Program Files文件\微软的Visual Studio 9.0 \ Common7 \ IDE \的ItemTemplate \ CSHARP \ 1033

作为UnitTestWizard.zip。

看起来好像在zip中的文件是当你打开它指向它正在运行一个dll在运行时生成的测试文件可能使用代码DOM事实的XML文件。

您可以看看T4模板这个或写一个VS插件做到这一点花不了多长时间写这个最小建立。

其他提示

您要的那本书是 “专业的Visual Studio扩展” 由Keyvan Nayyeri。这是一个很好的书,涵盖的Visual Studio扩展(VSX)的整个宽度,从宏最多的VSPackage。

一定要看看的Visual Studio扩展性开发中心 MSDN上。另外,我建议你下载并安装的 Visual Studio 2008的SDK 。有一些非常好的例子有,完成与源代码。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top