0

I can't run Unit Tests in my project, for about 4 days ago, I've already tried a lot of solutions that's existing in SO, but nothing helped me.

No test is available in Path\To\My\TestProject.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Test Explorer shows my tests, but can't run them.

Btw. These are WPF C# projects.

I have test classes with test methods like this:

    [TestFixture]
    [Category("Something")]
    public class SomeTestClass
    {
        [Test]
        public void SomeMethodThatDoesntWork()
        {
            using (var ms = new MemoryStream())
            {
                System.Diagnostics.Debugger.Launch();
                Option savedOptions = new ....
...
  • I have 3 projects in my solution, every project's Target framework is .NET 4.5.2 and every project's Platform Target is x64.

  • NuGet packages: NUnit 2.6.4 and NUnit3TestAdapter 3.12.0.

NUnit 2.6.4 because of I have some Attributes like ExpectedExceptionAttribute that is already removed in newer NUnit versions.

I've already set Test\Test Settings\Default Processor Achitecture to x64 and also tried x86.

Test Console Output:

enter image description here

Test Exlorer:

enter image description here

koviroli
  • 1,422
  • 1
  • 15
  • 27
  • Are you using Resharper? If so, which version? – Matthew Watson Feb 12 '19 at 09:26
  • I do not use Resharper. – koviroli Feb 12 '19 at 09:28
  • I guess you were using another version of VS, check do you have installed the NUnit VSAdapter in your IDE. I have had a similar problem, [this](https://stackoverflow.com/questions/29890768/nunit-doesnt-discover-tests-no-error-message) helped me. – sharp Feb 12 '19 at 10:09

3 Answers3

1

Finally solved my problem in about 2 days.

There was DLL dependencies which those Visual Studio couldn't notice and didn't show me any warning or errors. Dependency Walker helped me to find those dependencies of my DLLs.

So what I've learnt again? Visual Studio can be buggy and sometimes isn't really smart.

koviroli
  • 1,422
  • 1
  • 15
  • 27
1

What solved it for me was:

  • Go to and SELECT -> 'Test' Tab -> Test Settings -> Default Processor Architecture -> x64**

Run tests.

Itamar
  • 885
  • 1
  • 9
  • 17
0

You can try this i may solve your problem.

Also, you can in latest version of NUnit you can change ExpectedExceptionAttribute attribute to this (or other examples from comments) or just use following asserts:

Assert.Throws<Exception>(() => 
{
    // Test Code
});
Lemm
  • 196
  • 1
  • 9