3
votes

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);
        }
    }
}
1
If the NUnit adapter is having errors, they should show up in the output window of Visual Studio under Test in the dropdown. Is there anything there?Rob Prouse
Hi Rob. Under Output, 0 found. No error messages. Full message: ------ Discover test started ------ Discover test finished: 0 found (0:00:02.6861536)taylorswiftfan
Can you run your tests using NUnit console? It may reveal more helpful errors.Rob Prouse
Yes I can. I have trimmed the top, but the key section: <test-case name="Hello_World_Testing.HelloWorldTesting.addition" executed="True" result="Success" success="True" time="0.053" asserts="1" /> <test-case name="Hello_World_Testing.HelloWorldTesting.subtract" executed="True" result="Success" success="True" time="0.032" asserts="0">taylorswiftfan
Are you using the extension or the nuget for the runner? Also, any reason your tests can't be AnyCPU?Rob Prouse

1 Answers

5
votes

I had this issue and this worked for me.

Close Visual Studio Go to:

C:/Users/YourUsername/AppData/Local/Temp

Rename the file called: VisualStudioTestExplorerExtensions

-Open Visual Studio and rebuild solution