In NUnit 3, they've replaced the attribute "TestFixtureSetUp" with "OneTimeSetUp". However, it doesn't actually seem to work, unless I'm being 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(), and so _diskService is null. Am I doing something wrong here, or could this be a bug?
NUnit 3.0 is not supported by Resharper. You should install NUnit adapter and use VS to run your tests. That helped me. More details you can find here https://github.com/nunit/nunit/issues/1089
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With