Skip to content

Instantly share code, notes, and snippets.

@gbHeadspring
Created September 7, 2011 15:39
Show Gist options
  • Save gbHeadspring/1200910 to your computer and use it in GitHub Desktop.
Save gbHeadspring/1200910 to your computer and use it in GitHub Desktop.
Demonstrates the lifecycle of NUnit test method execution
using System;
using NUnit.Framework;
namespace NUnitLifecycle
{
[TestFixture]
public class TestClass : IDisposable
{
public TestClass()
{
Console.WriteLine("Constructor");
}
[TestFixtureSetUp]
public void TestClassSetUp()
{
Console.WriteLine("TestFixtureSetup");
}
[TestFixtureTearDown]
public void TestClassTearDown()
{
Console.WriteLine("TestFixtureTearDown");
}
[SetUp]
public void TestSetUp()
{
Console.WriteLine("SetUp");
}
[TearDown]
public void TestTearDown()
{
Console.WriteLine("TearDown");
}
[Test]
public void FirstTest()
{
Console.WriteLine("First Test passes!");
Assert.Pass();
}
[Test]
public void SecondTest()
{
Console.WriteLine("Second Test fails!");
Assert.Fail();
}
public void Dispose()
{
Console.WriteLine("Dispose");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment