Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 在Silverlight单元测试中使用TestCategory属性_Unit Testing_Silverlight 4.0_Attributes - Fatal编程技术网

Unit testing 在Silverlight单元测试中使用TestCategory属性

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

我正试图在Silverlight项目中编写一些单元测试,我想像在常规测试项目(VS2010)中那样用属性标记它们。例如,类似这样的内容:

[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);
}