Basic C# NUnit Test Setup

This post will outline the basic structure of how to setup your C# NUnit test. First of all here is the code of the basic empty C# NUnit test file. I’ll explain all of the different parts below.

namespace MyWebDriverTest
{
    [TestFixture]
    public class Class1
    {
        [Test]
        public void TestCase01()
        {

        }
    }
}

The two attributes [TestFixture] and [Test] are used by the NUnit Framework to indicate that there are tests to be executed. The [TestFixture] attributes is used by NUnit to indicate that the class contains test code. This class must be public and must also have a default constructor. The [Test] attribute indicates that the method is a test method. Test methods have to return a void and also must have no parameters.

Everything else is standard C# code for defining a class and a method.

This is the basic setup for a C# NUnit WebDriver test, and we will use this a s starting point for more in-depth tests in later posts.

One thought on “Basic C# NUnit Test Setup

Leave a Comment