Skip to content

DefaultTimeout in .runsettings + TearDown method seems to break test output #4598

@patrykpiotrmarek

Description

@patrykpiotrmarek

NUnit v4.0.1 (regression after upgrade from 3.x)

I have simple test class with TestContext.WriteLine in test method and TearDown method.

[TestFixture]
public class Tests
{
    [Test]
    public void Test1()
    {
        TestContext.WriteLine("line1");
        Assert.That(1, Is.EqualTo(0));
    }

    [TearDown]
    public void TearDown()
    {
    }
}

and .runsettings file with DefaultTimeout setting

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <NUnit>
    <DefaultTimeout>600000</DefaultTimeout>
  </NUnit>
</RunSettings>

When I run this code from dotnet test with --settings parameter, there is no output message other than assertion.

PS C:\NUnitTest\NUnitTest\bin\Debug\net8.0> dotnet test NUnitTest.dll --settings .\nunit.runsettings
Microsoft (R) Test Execution Command Line Tool Version 17.8.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
  Failed Test1 [20 ms]
  Error Message:
     Assert.That(1, Is.EqualTo(0))
  Expected: 0
  But was:  1

  Stack Trace:
     at NUnitTest.Tests.Test1() in C:\NUnitTest\NUnitTest\Tests.cs:line 12



Failed!  - Failed:     1, Passed:     0, Skipped:     0, Total:     1, Duration: 19 ms - NUnitTest.dll (net8.0)

Everything works fine after I remove TearDown method or DefaultTimeout setting

PS C:\NUnitTest\NUnitTest\bin\Debug\net8.0> dotnet test NUnitTest.dll --settings .\nunit.runsettings
Microsoft (R) Test Execution Command Line Tool Version 17.8.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
line1

  Failed Test1 [17 ms]
  Error Message:
     Assert.That(1, Is.EqualTo(0))
  Expected: 0
  But was:  1

  Stack Trace:
     at NUnitTest.Tests.Test1() in C:\NUnitTest\NUnitTest\Tests.cs:line 12

1)    at NUnitTest.Tests.Test1() in C:\NUnitTest\NUnitTest\Tests.cs:line 12


  Standard Output Messages:
 line1



Failed!  - Failed:     1, Passed:     0, Skipped:     0, Total:     1, Duration: 17 ms - NUnitTest.dll (net8.0)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions