Test is a "Lite" tool that reports the results of software tests. Latest improvement is the addition of helper methods FloatsAreEqualWithinFraction and FloatsAreEqualWithinTolerance to simplify testing floating point results that are not identical.

Benefits

  • It's entirely free.

  • It's only 195 lines, so it's understandable.

  • It's source code, so you can play with it.

  • It’s much lighter weight than NUnit or VS2005 Test.

  • It’s a batch-like tool, and runs as many tests as possible.

  • It doesn’t use Debug.Assert, so a test run doesn't stop to handle exceptions.

  • Each method is documented using XML style for viewing in the Object Browser.


Usage

  • Add a class to your project that will execute your tests, say,
        Class MyTester{}

  • Write your method(s)

  • In MyTester, add the code to test your methods by calling a Test instance.

  • Execute MyTester


Example

    Assume you're testing Test itself. This code might be typical:

    using EngineeringObjects.Tester;    //    Test namespace

    namespace SomePlace {
    class Program {
        static void Main(string[] args) {

            Test t = new Test( Console.Out );    //    Test instance

            t.AssertTrue( true, "AssertTrue" );
            t.AssertFalse( false, "AssertFalse" );

            double a = 1.0;
            double b = 1.0;
            t.AssertTrue( a == b, "Equal" );
            t.AssertTrue(t.FloatsAreEqualWithinFraction(a,b,0.01),"a within 1% of b");

            b = 2.0;
            t.AssertFalse( a == b, "Unequal" );
            t.WritePassed( "another passed test" );
            t.TheTextWriter.WriteLine( "writing to the TextWriter" );
            t.Report();

            Console.WriteLine( "Press Enter to end..." );
            Console.ReadLine(); //  wait for Enter key
        }
    }
}


Signatures in the Test class

namespace EngineeringObjects.Tester
{
      public class Test
      {
            public Test( TextWriter tw );
            public int TestsFailed {
                  get;
                  set;
            }
            public int TestsPassed {
                  get;
                  set;
            }
            public int TestsTotal {
                  get;
                  set;
            }
            public TextWriter TheTextWriter {
                  get;
            }
            public void AssertFalse( bool isTrue, string message );
            public void AssertTrue( bool isTrue, string message );
            public string Failed( string message );
            public bool FloatsAreEqualWithinFraction( double a, double b, double fraction );
            public bool FloatsAreEqualWithinTolerance( double a, double b, double tolerance );
            public string Passed( string message );
            public void Report();
            public void WriteFailed( string message );
            public void WritePassed( string message );
      }
}

 


Download*

Click here to download Program.cs and Test.cs in a ZIP archive (2KB)


*Free downloads may be used without restriction, although a citation would be "courteous."  Note well: We provide no guarantees that free downloads work, nor do we support them. They are offered 'as is'. See our Legal page for our complete and utter denial of responsibility for everything.