Bowling Game Kata Part One - Setup

The Bowling Game Kata was my first introduction to Test Driven Development. Uncle Bob wrote about it on his TheBowlingGameKata page.

This walk-through will use NUnit 3.

Goal

Write a simple class that scores a game of bowling.

Iteration 0 - The Setup

Create a class library and name the project "BowlingGame".

Before we write a line of production code, we want to have a failing test to cover it. In this example, I will be using NUnit 3 inside of a class library.

Add a new project to the Solution named "BowlingGame.Test".

After the project is created, add a class named GameTest.cs. Game is the name of the class we will be testing, and "Test" is just a suffix that I like to add to the end of tests.

Now add the [TestFixture] attribute to the top of GameTest.

BowlingGame.Test/GameTest.cs
namespace BowlingGame.Test
{
    [TestFixture]
    public class GameTest
    {
    }
}

Adding the TestFixture attribute causes a compile-time error. To fix it, we need to bring in the NUnit 3 package using NuGet.

Now that you added NUnit, you can add the using statement for the NUnit.Framework namespace.

BowlingGame.Test/GameTest.cs
using NUnit.Framework;

namespace BowlingGame.Test
{
    [TestFixture]
    public class GameTest
    {
    }
}