【发布时间】:2009-06-02 19:14:23
【问题描述】:
当我在 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 模板附近四处寻找)。在哪里更改此模板?
【问题讨论】:
-
我知道你的意思。我前段时间试过这个,发现测试代码是动态创建的。我最终的解决方案是使用 nUnit。
标签: visual-studio-2008 unit-testing t4 visual-studio-templates