I'm trying to use the TestContext.CurrentContext
of NUnit 2.6.2 but it's always null.
What I would like is to have an output with the result of tests, but if I run the following code I always get a NullReferenceException
in the TearDown
method.
All the properties inside Test and Result are throwing the exception.
[TestFixture]
public class UtilitiesTests
{
[TearDown]
public void TearDown()
{
//using console here just for sake of simplicity.
Console.WriteLine(String.Format("{0}: {1}", TestContext.CurrentContext.Test.FullName, TestContext.CurrentContext.Result.Status));
}
[Test]
public void CleanFileName()
{
var cleanName = Utilities.CleanFileName("my &file%123$99\\|/?\"*:<>.jpg");
Assert.AreEqual("my-efile12399---.jpg", cleanName);
}
}
What I'm possibly doing wrong?