- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 NUnit 3 中,他们用“OneTimeSetUp”替换了属性“TestFixtureSetUp”。然而,它实际上似乎不起作用,除非我是一个十足的白痴。
这是我的代码:
[TestFixture]
public class DiskServiceTests
{
private readonly Mock<IDriveInfoWrapper> _driveInfoWrapper = new Mock<IDriveInfoWrapper>();
private IDiskService _diskService;
[OneTimeSetUp]
public void Init()
{
_diskService = new DiskService(_driveInfoWrapper.Object);
}
[Test]
public void GetDriveInfo_ShouldReturnDriveInfo()
{
// Act
var result = _diskService.GetDriveInfo();
// Assert
Assert.IsNotNull(result);
}
}
测试将开始,但它永远不会进入 Init(),因此 _diskService 为 null。我在这里做错了什么吗,或者这可能是一个错误?
最佳答案
Resharper 不支持 NUnit 3.0。您应该安装 NUnit 适配器并使用 VS 来运行测试。这对我有帮助。您可以在这里找到更多详细信息 https://github.com/nunit/nunit/issues/1089
关于.net - NUnit 3 : OneTimeSetUp doesn't fire,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33916416/
可以使用 enable 在 nunit 开发的项目中,使用在 OneTimeSetup 中初始化的字段,但没有获取“警告 CS8618:不可为 null 的字段‘...’在退出构造函数时必须包含非 n
我正在使用 NUnit 运行一些 Selenium 测试,我遇到了一个小问题,我想看看是否可以得到更正。发生的情况是 [OneTimeSetUp] 和 [OneTimeTearDown] 在每个 fi
在 NUnit 3 中,他们用“OneTimeSetUp”替换了属性“TestFixtureSetUp”。然而,它实际上似乎不起作用,除非我是一个十足的白痴。 这是我的代码: [TestFixture
我们有一个集成测试套件,其中包含大量执行存储库类的测试。 目标是在 BaseTestFixture 中有一个 [OneTimeSetup] 方法,它将在所有测试之前和所有测试之后的拆卸中仅创建/填充每
我在与 Razor 应用程序结合MVVM进行集成测试时遇到问题。我所有的类都使用ApplicationDbContext。 测试类: [TestFixture] public class ApiPar
我目前正在使用 C#、nunit 和 Selenium 构建一个自动化项目,我正在尝试拥有一个安装类,它将在任何 TestFixture 之前初始化 selenium webdriver将运行并且在所
OneTimeSetUp 和 OneTimeTearDown 停止工作 using NUnit.Framework; using System; using System.Collections.Ge
我的单元测试是用 Nunit 2.6 编写的,但计划升级到 Nunit 3.6.1,但是我注意到 Nunit 3.6.1 有一个奇怪的问题(或者可能是我没有正确理解)。问题出在 OneTimeSetU
我的单元测试是用 Nunit 2.6 编写的,但计划升级到 Nunit 3.6.1,但是我注意到 Nunit 3.6.1 有一个奇怪的问题(或者可能是我没有正确理解)。问题出在 OneTimeSetU
我遇到一个问题,NUnit 告诉我:“找不到合适的构造函数”。是什么原因造成的?我还收到另一条消息:“Exception doesn't have a stacktrace”。这两条消息只是一遍又一遍
我在 Nunit 3 测试用例中陷入了奇怪的情况,我在 [SetUpFixture] 中的 [OneTimeSetUp] 在 [Test, TestCaseSource(typeof(TestData
我是一名优秀的程序员,十分优秀!