【发布时间】:2013-09-26 21:19:21
【问题描述】:
我似乎无法使用 Visual Studio 2012 为 Windows 商店应用程序运行单元测试。
为了配置我的应用程序,我已经完成了以下步骤。
- 我创建了一个 Windows 商店项目。我构建它并让它运行良好。
- 然后右键单击解决方案,然后单击添加 > 新项目。从“添加新项目菜单”中选择项目模板“单元测试库(Windows 应用商店应用程序)”,然后单击“确定”创建项目。
- 我创建了一个类似于以下内容的基本单元测试。
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 - 我打开 Visual Studio 测试探索,显示以下内容。
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) ==========
测试资源管理器仍然显示与构建之前相同的消息,即“构建您的解决方案以发现所有可用测试......
即便如此,我还是尝试点击全部运行。
这导致构建的以下输出
========== Build: 0 succeeded, 0 failed, 2 up-to-date, 0 skipped ==========
测试没有输出
不用说,测试资源管理器中没有显示测试已运行、通过、跳过或失败。
我确保 UnitTest 项目的配置属性设置为构建和部署,并尝试使用每个平台配置(任何 CPU、x86 和 x4)进行构建
【问题讨论】:
-
您提供的链接说明了有关更新清单的内容。是你做的吗?愚蠢的问题:您是否尝试重新启动VS?
-
是的,我试过重启VS,甚至重启了整台电脑。至于更新清单,这是一个选项步骤。 “您选择的功能应仅包括 Windows 应用商店单元测试所需的功能”。话虽如此,我确实尝试更新它只是为了看看是否会有所作为,但无济于事。
-
你试过重建吗?
-
是的,我已经尝试过重建
-
作为一个单元测试库,是否不需要有Windows Store App作为参考/依赖?确保构建顺序和依赖列表反映了这一点。
标签: c# unit-testing visual-studio-2012 windows-store-apps