Unit testing 在Silverlight单元测试中使用TestCategory属性
我正试图在Silverlight项目中编写一些单元测试,我想像在常规测试项目(VS2010)中那样用属性标记它们。例如,类似这样的内容:Unit testing 在Silverlight单元测试中使用TestCategory属性,unit-testing,silverlight-4.0,attributes,Unit Testing,Silverlight 4.0,Attributes,我正试图在Silverlight项目中编写一些单元测试,我想像在常规测试项目(VS2010)中那样用属性标记它们。例如,类似这样的内容: [TestMethod] [TestCategory("BVT")] public void TestMethod1() { } [TestMethod] [Tag("BVT")] public void TestMethod1() { } private void Application_Startup(object sender, StartupEve
[TestMethod]
[TestCategory("BVT")]
public void TestMethod1()
{
}
[TestMethod]
[Tag("BVT")]
public void TestMethod1()
{
}
private void Application_Startup(object sender, StartupEventArgs e)
{
UnitTestSettings settings = UnitTestSystem.CreateDefaultSettings();
settings.SampleTags.Clear();
settings.SampleTags.Add("All");
settings.SampleTags.Add("BVT");
RootVisual = UnitTestSystem.CreateTestPage(settings);
}
我添加了对Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll的引用,在尝试标记测试用例时,TestCategory属性不可用
是否有办法使用Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll中提供的所有成员/属性??我不能添加它作为参考,因为我在Silverlight项目中工作
谢谢 您可以这样标记您的方法:
[TestMethod]
[TestCategory("BVT")]
public void TestMethod1()
{
}
[TestMethod]
[Tag("BVT")]
public void TestMethod1()
{
}
private void Application_Startup(object sender, StartupEventArgs e)
{
UnitTestSettings settings = UnitTestSystem.CreateDefaultSettings();
settings.SampleTags.Clear();
settings.SampleTags.Add("All");
settings.SampleTags.Add("BVT");
RootVisual = UnitTestSystem.CreateTestPage(settings);
}
您还可以通过如下更改App.xaml.cs来自定义Silverlight Framework UI示例:
[TestMethod]
[TestCategory("BVT")]
public void TestMethod1()
{
}
[TestMethod]
[Tag("BVT")]
public void TestMethod1()
{
}
private void Application_Startup(object sender, StartupEventArgs e)
{
UnitTestSettings settings = UnitTestSystem.CreateDefaultSettings();
settings.SampleTags.Clear();
settings.SampleTags.Add("All");
settings.SampleTags.Add("BVT");
RootVisual = UnitTestSystem.CreateTestPage(settings);
}