Skip to content

Instantly share code, notes, and snippets.

@gbHeadspring
Created October 4, 2011 18:44
Show Gist options
  • Save gbHeadspring/1262440 to your computer and use it in GitHub Desktop.
Save gbHeadspring/1262440 to your computer and use it in GitHub Desktop.
using System;
using NUnit.Framework;
namespace NUnitLifecycle
{
public abstract class TestBase : IDisposable
{
protected TestBase()
{
Console.WriteLine("Base Constructor");
}
[TestFixtureSetUp]
public void BaseTestFixtureSetUp()
{
Console.WriteLine("Base TestFixtureSetup");
}
[TestFixtureTearDown]
public void BaseTestFixtureTearDown()
{
Console.WriteLine("Base TestFixtureTearDown");
}
[SetUp]
public void BaseTestSetUp()
{
Console.WriteLine("Base SetUp");
}
[TearDown]
public void BaseTestTearDown()
{
Console.WriteLine("Base TearDown");
}
[Test]
public void BaseFirstTest()
{
Console.WriteLine("Base First Test passes!");
Assert.Pass();
}
[Test]
public void BaseSecondTest()
{
Console.WriteLine("Base Second Test fails!");
Assert.Fail();
}
public virtual void Dispose()
{
Console.WriteLine("Base Dispose");
}
}
[TestFixture]
public class TestClass : TestBase
{
public TestClass()
{
Console.WriteLine("Derived Constructor");
}
[TestFixtureSetUp]
public void TestClassSetUp()
{
Console.WriteLine("Derived TestFixtureSetup");
}
[TestFixtureTearDown]
public void TestClassTearDown()
{
Console.WriteLine("Derived TestFixtureTearDown");
}
[SetUp]
public void TestSetUp()
{
Console.WriteLine("Derived SetUp");
}
[TearDown]
public void TestTearDown()
{
Console.WriteLine("Derived TearDown");
}
[Test]
public void FirstTest()
{
Console.WriteLine("Derived First Test passes!");
Assert.Pass();
}
[Test]
public void SecondTest()
{
Console.WriteLine("Derived Second Test fails!");
Assert.Fail();
}
public override void Dispose()
{
Console.WriteLine("Derived Dispose");
base.Dispose();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment