mercredi 27 juillet 2016

Tests not showing up in Test Explorer (Nunit)

The problem: My NUnit tests are not showing up in Test Explorer.

I am currently running Visual Studio Express 2013 on a 64-bit machine. At present, I have "NUnit TestAdapter including NUnit 2.6.4 framework" installed. The framework version is 2.6.4.14350, while the test adapter version is 2.0.0.0

Following these two threads (NUnit Unit tests not showing in Test Explorer with Test Adapter is installed and Visual Studio 2013 doesn't discover unit tests) on troubleshooting:

  • At present, "Active Solution Platform" is set to 64-bit for build settings for my test project (Build > Configuration Manager).

  • "Default Processor Architecture" is pointed to 64-bit under Test > Test Settings.

  • A reference to both NUnit framework and TestAdapter have been specified in the test project.

  • The test project cs file contains [TestFixture] and [Test] in the correct places
  • I have tried cleaning / rebuilding the solution multiple times
  • I have tried restarting Visual Studio multiple times
  • I have tried running Visual Studio via "Run as administrator"
  • I have tried running NUnit version 3 (framework and test adapter)

Below is my code:

using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hello_World_Testing
{
    [TestFixture]
    public class HelloWorldTesting
    {
        [Test]
        public void subtract()
        {
            int value = 1;

            if (value == 1)
            {
                Assert.Pass();
            }
        }

        [Test]
        public void addition()
        {
            int firstValue = 1;
            int secondValue = 2;

            Assert.AreEqual(3, firstValue + secondValue);
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire