NUnit 3: OneTimeSetUp not working

In NUnit 3, they replaced the attribute "TestFixtureSetUp" with "OneTimeSetUp". However, in reality this does not work unless I am a complete idiot.

This is my code below:

[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); } } 

The test will start, but it never goes into Init (), so _diskService is null. Am I doing something wrong here, or could it be a mistake?

+5
source share
1 answer

NUnit 3.0 is not supported by Resharper. You must install the NUnit adapter and use VS to run your tests. It helps me. More information can be found here https://github.com/nunit/nunit/issues/1089

+6
source

Source: https://habr.com/ru/post/1236805/


All Articles