Skip to content

Instantly share code, notes, and snippets.

@adamvlasak
Last active April 15, 2021 17:41
Show Gist options
  • Save adamvlasak/89b99dbb0a5740290fb3bef5befc5ce9 to your computer and use it in GitHub Desktop.
Save adamvlasak/89b99dbb0a5740290fb3bef5befc5ce9 to your computer and use it in GitHub Desktop.
using NUnit.Framework;
[SetUpFixture]
public class RootFixtureSetup
{
[OneTimeSetUp]
public void OneTimeSetUp() => TestContext.Progress.WriteLine("RootFixtureSetup:OneTimeSetUp");
[OneTimeTearDown]
public void OneTimeTearDown() => TestContext.Progress.WriteLine("RootFixtureSetup:OneTimeTearDown");
}
namespace TestLifeCycle
{
[SetUpFixture]
public class FixtureSetup
{
[OneTimeSetUp]
public void OneTimeSetUp() => TestContext.Progress.WriteLine("FixtureSetup:OneTimeSetUp");
[OneTimeTearDown]
public void OneTimeTearDown() => TestContext.Progress.WriteLine("FixtureSetup:OneTimeTearDown");
}
[TestFixture]
public class Tests
{
[OneTimeSetUp]
public void OneTimeSetUp() => TestContext.Progress.WriteLine("Tests:OneTimeSetUp");
[SetUp]
public void Setup() => TestContext.Progress.WriteLine("Tests:SetUp");
public Tests() => TestContext.Progress.WriteLine("Tests:Constructor");
[Test]
public void Test1() => TestContext.Progress.WriteLine("Tests:Test1");
[Test]
public void Test2() => TestContext.Progress.WriteLine("Tests:Test2");
[TearDown]
public void TearDown() => TestContext.Progress.WriteLine("Tests:TearDown");
[OneTimeTearDown]
public void OneTimeTearDown() => TestContext.Progress.WriteLine("Tests:OneTimeTearDown");
}
}
@adamvlasak
Copy link
Author

adamvlasak commented Apr 15, 2021

RootFixtureSetup:OneTimeSetUp
FixtureSetup:OneTimeSetUp
Tests:Constructor
Tests:OneTimeSetUp
Tests:SetUp
Tests:Test1
Tests:TearDown
Tests:SetUp
Tests:Test2
Tests:TearDown
Tests:OneTimeTearDown
FixtureSetup:OneTimeTearDown
RootFixtureSetup:OneTimeTearDown
NUnit Adapter 3.16.1.0: Test execution complete
----- Test Execution Summary -----

TestLifeCycle.Tests.Test1:
    Outcome: Passed
    
TestLifeCycle.Tests.Test2:
    Outcome: Passed
    
Total tests: 2. Passed: 2. Failed: 0. Skipped: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment