因此,与 Visual Studio 2010 相比,右键单击方法时,上下文菜单中没有“创建单元测试”,这让我感到惊讶。
建议的解决方法是在 VS2010 中创建单元测试,然后将其导入回 VS2012。
然后我发现这篇文章http://dl.my/2013/enable-create-unit-tests-on-visual-studio-2012/ 确实有效!
但是现在,当我在方法上单击“创建单元测试”后,生成的类只包含一个 TestContext 属性,没有之前在向导中选择的测试方法。
这是生成的类:
/// <summary>
///This is a test class for XXXTest and is intended
///to contain all XXXTest Unit Tests
///</summary>
[TestClass()]
public class XXXTest
{
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;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
}
我在网上搜索了没有结果..
有人知道这里有什么问题吗?