If test fixtures could be private

Last one for the day, then I go home.

You’ve read Test Methods are neither Methods nor Tests. You’ve dried off & are fully recovered.

This is the practical reason why NUnit should remove the ‘public’ requirements from test fixtures. I didn’t include it in the last post, because I didn’t want people to focus on the concrete impacts of my reasoning.

Today, NUnit sets you up to write like this:

   class MyClass

   {

      //...

   }

   //------------

   // may be same file, different file in the same project, different netmodule, different assembly

   [TestClass]

   public class MyClassTests

   {

      [TestMethod]

      public void Test1()

      {

         //...

      }

   }

I prefer to write like this:

   class MyClass

   {

      //...

      [TestClass]

      /*public*/ class Tests

      {

         [TestMethod]

         /*public*/ void Test1()

         {

            //...

         }

      }

   }

It lets me normalize my naming. Tests for MyClass are called “MyClass.Tests”.

A Rename Refactoring of MyClass to YourClass, I won’t miss MyClassTests from the first example, because I’ve removed that duplication from my code.

 

BTW, I'm 0x1E today. Instead of taking the day off, I decided to spend the day doing only work I enjoy. Hence 8 full-featured blogs in one day.