Unit Testing

General

While test driven development isn't a required in order to contribute to this project, unit testing is still required for all submitted code. All unit tests will be done using the NUnit framework. Please don't be lazy when writing unit tests and just write the simplest possible test to show that under very specific circumstances the code works. For most functionality, passing and failing tests should be created to show that the code handles 'misuse' properly. In some cases, multiple tests should be created in order to perform range testing. To sum up: any source submitted to the project cannot be accepted into the code base until adequate NUnit testing exists.

Rational

During development, most developers have some method of testing their code to ensure that it's doing what they expect. While this seems adequate, without an automated form of testing all source, full regression becomes near impossible. Because the NUnit framework works for both .Net and Mono, and because they will both integrate with NUnit (look at JetBrains UnitRun for .Net integration) NUnit is the only acceptable testing tool at this time.

Examples

Good

using System;
using NUnit.Framework;
 
[TestFixture]
public class MyTest
{
    [Test]
    public void Succeeding()
    {
        DataInterface dbInterface = new DataInterface("... valid connection string ...");
        dbInterface.Connection.Open();
        Assert.IsTrue(dbInterface.Connection.State == ConnectionState.Open);
    }
 
    [Test]
    public void Failing()
    {
        DataInterface dbInterface = new DataInterface("...invalid connection string...");
        Assert.Fail();
    }
}

Bad

using System;
using NUnit.Framework;
 
[TestFixture]
public class MyTest
{
    [Test]
    public void Succeeding()
    {
        DataInterface dbInterface = new DataInterface("... valid connection string ...");
    }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.