Nunit - doesn't discover tests [no error-messa

2020-05-20 07:43发布

Unit refuses to dsicover or run my tests in an assembly. This is not the case where Unit produces an error message like "Unable to find test in assembly". It simply doesn't discover that I have tests.

I right-click the test-method and the test output shows:

Discover test started ------ Discover test finished: 0 found (0:00:00,0260026)"

I have tried everything mentioned in this post: NUnit doesn't find tests in assembly

Upgrading is not a possiblity. The processor architecture settings are correct. My tests are public and have all the correct tags.

Here's some code from my project that I simply can't get to even execute. I know that because I have a break-point right at the beginning.

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

namespace UnitTestProjects
{
    [TestFixture]
    public class SomeRandomTests
    {
        [Test]
        public void ShouldFail()
        {
            Assert.AreEqual(1, 0);
        }

        [Test]
        public void ShouldPass()
        {
            Assert.AreEqual(1,1);
        }
    }
}

I'm running the internal visual studio test explorer. Unit Framework version 2.5.9.10348, runtime version v2.0.50727. I have Unit Test Adopter installed. I've attempted reinstalling it with no success.

8条回答
Viruses.
2楼-- · 2020-05-20 08:02

For my case VS2017, after installation of Unit Test Adopter 3, I just add an updated version of the DLL to my solution using Nuget Package manager.

查看更多
Anthone
3楼-- · 2020-05-20 08:03

Mine is just like the same, but the different was I created my project as VS UnitTest project and not a plain DLL. So I created a DLL and referenced all the nunit assemblies and the test are now discovered.

Hope this helps.

查看更多
啃猪蹄的小仙女
4楼-- · 2020-05-20 08:08

Problem may be with NUnit30Settings.xml. I had this poroblem. In my case file was empty. I don't know what was the reason. I copied settings from NUnitSettings.xml to NUnit30Settings.xml. This solved my problem. Files with settings are in ...Users\[User]\AppData\Local\NUnit.

查看更多
劳资没心,怎么记你
5楼-- · 2020-05-20 08:14

In my case i used TestCaseSource attribute. And passed wrong sourceName.

 [Test]
 [TestCaseSource("TestDataCaseSource")]
 public void SomeTest1(string DataName, ITestData testData)

After fixing it, all tests appears in Test Explorer

查看更多
时光不老,我们不散
6楼-- · 2020-05-20 08:17

I had this same problem when upgrading from Visual Studio 2013 to VS 2017. In my case, all the tests were written for NUnit 2 (not 3) and worked fine in VS 2013. Once VS2017 was installed, none of the tests could be found.

The problem is that VS2017 did not automagically pick up the NUnit 2 install on my VM.

The solution was to install the Nunit 2 test runner by clicking on the Tools menu, Tools | Extensions and Updates. Next select Online on the right-hand list and then enter "NUnit" in the Search box. You can then add the appropriate NUnit test runner.

This probably applies to all test runners except perhaps MSTest.

查看更多
我命由我不由天
7楼-- · 2020-05-20 08:18

I was also facing same issue.My tests are not discovered. After installing NUnit3TestAdapter dll from nuget package manager resolved my issue.my visual studio version is vs2017.

查看更多
登录 后发表回答