Created
September 7, 2011 15:39
-
-
Save gbHeadspring/1200910 to your computer and use it in GitHub Desktop.
Demonstrates the lifecycle of NUnit test method execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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