To implement, simply reference the ObviousCode.TestRunner dll and call test classes as below:

Tests can be run using the Tester.RunTestsInClass<T>. The class T should be decorated with the TestFixtureAttribute, and will recognise the following attributes:
  • TestFixtureAttribute
  • TestFixtureSetUpAttribute
  • TestFixtureTearDownAttribute
  • SetUpAttribute
  • TearDownAttribute
  • TestAttribute
  • ExpectedExceptionAttribute (as well as the ExpectedException type and message parameters)

Console example of using NHarness TestRunner

   public class RunTests
    {
        public static void Main(string[] args)
        {
            TestResults results = Tester.RunTestsInClass<Tests>();
          
            Console.WriteLine("Tests Run: {0}", results.NumberOfResults);
            Console.WriteLine("Results {0}:PASSED {1}:FAILED", results.NumberOfPasses, results.NumberOfFails);
            Console.WriteLine("Details:");

            foreach (TestResult result in results)
            {
                Console.WriteLine("Test {0}: {1} {2}",
                                            result.MethodName,
                                            result.Result,
                                            result.Result == TestResult.Outcome.Fail ? "\r\n" + result.Message : "");
            }

            Console.ReadLine();
        }
    

Last edited Nov 10, 2011 at 8:05 AM by obviouscode, version 2

Comments

No comments yet.