【问题标题】:NullReferenceException with Assert.That and NunitLite带有 Assert.That 和 NunitLite 的 NullReferenceException
【发布时间】:2015-03-13 00:20:20
【问题描述】:

我正在使用 NunitLite 对 Xamarin 项目进行单元测试。

环境:

  • Windows 8.1 64 位
  • Visual Studio 2012
  • 测试项目类库引用 .NET 4.5
  • 来自 NuGet 的 NunitLite V1.0.0 包 - 包含 .NET 4.5 的构建
  • 使用来自 NuGet 的 Nunit 测试适配器 V1.2 运行测试

即使是最简单的测试:

[Test]
public void SimpleTest()
{
    Assert.That(1 == 1);
}

我遇到了异常:

System.NullReferenceException 未被用户代码处理
HResult=-2147467261 消息=对象引用未设置为实例 的一个对象。来源=nunitlite StackTrace: 在 NUnit.Framework.Assert.IncrementAssertCount() 在 NUnit.Framework.Assert.That(对象实际,IResolveConstraint 表达式,字符串消息,对象 [] args) 在 NUnit.Framework.Assert.That(布尔条件) 在 SportLogger.Tests.Unit.Core.when_using_venue_manager.SimpleTest() 中 c:\SportLogger\SportLogger.Tests.Unit.Core\CoreTests.cs:第 65 行 InnerException:

有没有人指出问题出在哪里?

【问题讨论】:

    标签: nunit


    【解决方案1】:

    我通过使用标准 Nunit 而不是 NunitLite 解决了这个问题。我不确定为什么 NunitLite 不能在标准 Windows 测试库中工作。

    请记住,NunitLite 旨在(在此上下文中)用于 iOS 和 Android 项目,核心测试项目切换到 Nunit,iOS 和 Android 测试项目切换到 NunitLite 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2013-01-04
      • 1970-01-01
      • 2013-04-11
      • 1970-01-01
      • 2014-08-24
      • 2021-10-02
      • 2016-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多