unit-testingmodel-view-controllernunitgallio

Running NUnit tests with Gallio


I'm trying to write some NUnit tests for a project. I add a new Class Library to the solution. Is this the correct project type?

I added a reference:

using NunitFramework;

and added my tests.

I have Gallio installed, but I'm unsure about whether it's configured properly. I'm new to using this, and I'm hoping someone can tell me how you actually run the tests.

It was my understanding you could right click and select run all tests. Alternatively I thought you could click on the [Test] attribute and click run or debug.

Alternatively, how do I load tests into the Test Results window to run debug them?


Solution

  • Basically it's correct. Your unit test should look like this:

    using System;
    using NUnit.Framework;
    
    namespace Demo
    {
      [TestFixture]
      public class SampleTestFixture
      {
          [Test]
          public void SampleTest()
          {
             // my test here...
          }
      }
    }
    

    Compile your test project (a class library is OK) in debug mode. Now you can run your test suite within any runner that supports NUnit: