【问题标题】:xUnit test appears in "External" category and won't run normallyxUnit 测试出现在“外部”类别中,无法正常运行
【发布时间】:2017-06-13 19:34:03
【问题描述】:

我正在使用带有 xUnit 2 的 Visual Studio 2015 和 Visual Studio 测试运行程序。 I have this sample project that exhibits the following problem:

如果我从方法返回stringTask<string>MyObject,测试将正常显示在测试资源管理器中。

但是,如果我返回 Task<MyObject>,测试将出现在“外部”类别下,并且当我在编辑器中单击“运行测试”时不会运行。

这可能是什么原因造成的?我发现了两个听起来相似的 Stack Overflow 问题,但它们似乎并不适用:

以下是来自 Visual Studio 的“关于”页面的信息。

Microsoft Visual Studio Professional 2015 版本 14.0.25431.01 更新 3 Microsoft .NET 框架版本 4.6.01586

安装版本:专业版

适用于 Visual Studio 2015 的 LightSwitch 00322-40000-00000-AA445 Microsoft 适用于 Visual Studio 2015 的 LightSwitch

Microsoft Visual Studio 应用程序工具 2015
00322-40000-00000-AA445 适用于应用程序的 Microsoft Visual Studio 工具 2015

Visual Basic 2015 00322-40000-00000-AA445 Microsoft Visual Basic 2015

Visual C# 2015 00322-40000-00000-AA445 Microsoft Visual C# 2015

Visual C++ 2015 00322-40000-00000-AA445 微软 Visual C++ 2015

Visual F# 2015 00322-40000-00000-AA445 Microsoft Visual F# 2015

适用于 Visual Studio 包 7.17.00119.9 的 Application Insights 工具 适用于 Visual Studio 的 Application Insights 工具

ASP.NET 和 Web 工具 2015.1 14.1.20907.0 ASP.NET 和 Web 工具 2015.1

ASP.NET Web 框架和工具 2012.2 4.1.41102.0 更多 信息,请访问http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web 框架和工具 2013 5.2.40314.0 更多 信息,请访问http://www.asp.net/

Azure 应用服务工具 v2.8.1 14.0.11123.0 Azure 应用服务工具 v2.8.1

Breakpoint Generator 1.0 自动为所有人生成跟踪点 解决方案中的公共入口点。

Common Azure Tools 1.8 提供常用服务供 Azure 使用 移动服务和 Microsoft Azure 工具。

JavaScript 语言服务 2.0 JavaScript 语言服务

JavaScript 项目系统 2.0 JavaScript 项目系统

JetBrains ReSharper Ultimate 2016.1.2 Build 105.0.20160522.80219 适用于 Microsoft Visual Studio 的 JetBrains ReSharper Ultimate 包。为了 有关 ReSharper Ultimate 的更多信息,请访问 http://www.jetbrains.com/resharper。版权所有 © 2017 JetBrains, Inc.

Markdown Editor 1.10.186 一个全功能的 Markdown 编辑器,带有实时 预览和语法高亮。支持 GitHub 风格的 Markdown。

Microsoft .NET Core 工具(预览版 2)14.1.20907.0 Microsoft .NET 核心工具(预览版 2)

Microsoft Azure 移动服务工具 1.4 Microsoft Azure 移动 服务工具

NuGet 包管理器 3.5.0 Visual Studio 中的 NuGet 包管理器。 有关 NuGet 的更多信息,请访问http://docs.nuget.org/

PreEmptive Analytics Visualizer 1.2 Microsoft Visual Studio 扩展以可视化来自 PreEmptive 的聚合摘要 分析产品。

SQL Server 分析服务 13.0.1700.68 Microsoft SQL Server 分析服务设计器版本 13.0.1700.68

SQL Server 数据工具 14.0.60812.0 Microsoft SQL Server 数据工具

SQL Server 集成服务 Microsoft SQL Server 集成 服务设计器版本 13.0.1601.5

SQL Server 报告服务 13.0.1700.68 Microsoft SQL Server Reporting Services 设计器版本 13.0.1700.68

TargetFrameworkMigrator 1.0 批量更改 .Net 项目目标 框架

TypeScript 1.8.36.0 用于 Visual Studio 的 TypeScript 工具

适用于通用 Windows 应用程序的 Visual Studio 工具 14.0.25420.01 适用于通用 Windows 应用程序的 Visual Studio 工具允许您构建一个 单一的通用应用程序体验,可以覆盖所有正在运行的设备 Windows 10:手机、平板电脑、PC 等。它包括微软 Windows 10 软件开发工具包。

VsVim 2.2.0.0 VsVim 是 Visual Studio 的 Vim 模拟器

Web Essentials 2015.3 3.0.235 为 Visual 添加了许多有用的功能 Web 开发人员的工作室。需要 Visual Studio 2015

Windows 安装程序 XML 工具集 3.10.3.3007 Windows 安装程序 XML 工具集版本 3.10.3.3007 版权所有 (c) .NET Foundation 和 贡献者。保留所有权利。

【问题讨论】:

    标签: visual-studio visual-studio-2015 xunit


    【解决方案1】:

    在使用async Task<MyObject> 调用时,我也有几个测试被神秘地标记为“外部”。我的解决方法是在测试程序集中定义MyObject。显然,这不是适用于所有情况的解决方案,但它对我有用,因为我只是在这些有问题的异步函数调用中将 JSON 数据反序列化为 POCO 对象。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-12
      • 1970-01-01
      • 2018-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多