2013-09-26 101 views
3

运行的Windows Store应用程序的单元测试,我似乎无法以配置我的应用程序使用Visual Studio 2012不能在Visual Studio 2012

我已经通过下面的步骤去运行的Windows Store应用程序的单元测试。

  1. 我创建了一个windows store项目。我构建它并让它运行得很好。
  2. 我比右键单击解决方案,然后单击添加>新建项目。从'添加新项目菜单'中,选择项目模板'单元测试库(Windows Store应用程序),然后单击确定创建项目。
  3. 我创建了一个如下所示的基本单元测试。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; 

namespace UnitTestLibrary1 
{ 
    [TestClass] 
    public class UnitTest1 
    { 
    [TestMethod] 
    public void TestMethod1() 
    { 
     string a = "a"; 
     string b = "b"; 

     Assert.AreEqual(a, b); 
    } 
    } 
} 

**注具体根据instructions found on the MSDN website here I have not built the Unit Test project yet

4 - I打开Visual Studio测试探索,其显示如下。

enter image description here

5 - 我着手构建整个解决方案(下面是构建输出)

1>------ Build started: Project: vevo.pushclient, Configuration: Debug Any CPU ------ 
2>------ Build started: Project: UnitTestLibrary1, Configuration: Debug Any CPU ------ 
2> UnitTestLibrary1 -> C:\Source\simple_push_client\vevo.pushclient\UnitTestLibrary1\bin\Debug\UnitTestLibrary1.dll 
1> vevo.pushclient -> C:\Source\simple_push_client\vevo.pushclient\vevo.pushclient\bin\Debug\vevo.pushclient.exe 
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== 

下面是从测试的输出,我试着用搜索引擎的错误,但找不到任何有用的答案

------ Discover test started ------ 
MSTestAdapter failed to discover tests in class 'UnitTestLibrary1.UnitTest1' of assembly 'C:\Source\simple_push_client\vevo.pushclient\UnitTestLibrary1\bin\Debug\UnitTestLibrary1.dll'. Reason Method not found: 'System.String Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestCategoryBaseAttribute.get_TestCategory()'.. 
NUnit 0.97.0.0 discovering tests is started 
NUnit 0.97.0.0 discovering test is finished 
========== Discover test finished: 0 found (0:00:00.1800223) ========== 

测试浏览器仍然表现出了同样的信息作为表示“构建解决方案,以discov构建之前呃所有可用的测试....

即使如此,我尝试点击运行所有。

这导致下面的输出为构建

========== Build: 0 succeeded, 0 failed, 2 up-to-date, 0 skipped ========== 

而且没有输出测试

不用说没有测试显示为已经运行,顺利通过,跳过,或者在测试失败探险家。

我保证了单元测试项目的配置属性被设置为构建和部署,并试图利用各平台配置来构建(任何CPU,x86和4个)

enter image description here

+0

您提供的链接提供了有关更新清单的信息。是你做的吗?愚蠢的问题:你尝试重新启动VS? – meilke

+0

是的,我试过重新启动VS,甚至重新启动整个计算机的踢。至于更新清单,这是一个选项步骤。 “您选择的功能应该只包含Windows Store单元测试所必需的功能。”这就是说,我确实尝试更新它只是为了看看是否会有所作为,但无济于事。 – pat8719

+0

你试过重建吗? –

回答

0

它告诉你您在测试方法中缺少属性...

MSTestAdapter未能在程序集“C:\ Source \ simple_push_client \ vevo.pushclient \ UnitTestLibrary1 \ bin \ Debug \ UnitTestLibrary1”类的“UnitTestLibrary1.UnitTest1”中发现测试。 DLL”。 Reason Method not found:'System.String Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestCategoryBaseAttribute.get_TestCategory()'..

不知道为什么,它不应该是必需的。但添加属性:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; 

namespace UnitTestLibrary1 
{ 
    [TestClass] 
    public class UnitTest1 
    { 
    [TestMethod] 
    [TestCategory("tests")] <! -- Added Attribute --> 
    public void TestMethod1() 
    { 
     string a = "a"; 
     string b = "b"; 

     Assert.AreEqual(a, b); 
    } 
    } 
} 

该类别可以是任何你想要的。不知道为什么它这样做,类别应该是一个可选参数。