2013-09-26 100 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); 
    } 
    } 
} 

該類別可以是任何你想要的。不知道爲什麼它這樣做,類別應該是一個可選參數。