Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit 2.6.3 - Tests not executing with message Test adapter sent back a result for an unknown test case

I am playing with NUnit 2.6.3 and I did this tests:

using NUnit.Framework;
using System;

namespace NUnit26Tests
{
    [TestFixture]
    public class RandomTests
    {
        [Test]
        public void RandomTest([Random(1, 100, 5)] int value)
        {
            Assert.IsTrue(true);
        }

        [Test]
        public void SuccessTests()
        {
            Assert.That(true, Is.True);
        }
    }
}

But most of the execution times (99%) RandomTest is not executing on Test Runner.

This is the output message window:

------ Discover test started ------
NUnit 1.0.0.0 discovering tests is started
NUnit 1.0.0.0 discovering test is finished
========== Discover test finished: 6 found (0:00:00,9970583) ==========
------ Run test started ------
NUnit 1.0.0.0 executing tests is started
Run started: C:\TestProjects\NUnit26Tests\NUnit26Tests\bin\Debug\NUnit26Tests.dll
NUnit 1.0.0.0 executing tests is finished
Test adapter sent back a result for an unknown test case. Ignoring result for 'RandomTest(92)'.
Test adapter sent back a result for an unknown test case. Ignoring result for 'RandomTest(38)'.
Test adapter sent back a result for an unknown test case. Ignoring result for 'RandomTest(69)'.
Test adapter sent back a result for an unknown test case. Ignoring result for 'RandomTest(96)'.
========== Run test finished: 2 run (0:00:09,271531) ==========

In this case only one of five RandomTest's was executed.

I have tested with runner Nuget Package and installing NUnit Runner extension, same result.

Any idea what is the problem ?

like image 442
ferpega Avatar asked Jan 13 '14 23:01

ferpega


People also ask

What is NUnit 3 test adapter?

The NUnit 3 Test Adapter allows you to run NUnit 3 tests inside Visual Studio. This is a new adapter, based partly on the code of the original NUnit Test Adapter, but modified to work with NUnit 3. It is not possible to run NUnit 2. x tests using this adapter.

What is the use of NUnit test adapter?

The NUnit Test Adapter allows you to run NUnit tests inside Visual Studio. The current release, version 0.92, is designed to work with the Visual Studio 11 Beta Release. Releases of Visual Studio prior to VS 11 did not have the ability to directly run tests built with Open Source testing frameworks like NUnit.

What is test runner in NUnit?

The nunit.exe program is a graphical runner. It shows the tests in an explorer-like browser window and provides a visual indication of the success or failure of the tests. It allows you to selectively run single tests or suites and reloads automatically as you modify and re-compile your code.


1 Answers

I was able to reproduce this behavior. This seems to be a bug within the NUnit framework and/or the Test Adapter.

My guess is, that the random values are drawn once before the tests are run (to display them) and once when run. The random values drawn will probably not match and so the test results may not be assigned, leading to the mentioned error message.

You could open a bug for this issue at the project's development site (https://launchpad.net/nunitv2), but they are heavily busy with the upcoming v3 release.

As a workaround for your issue I propose that you use static (random) values (not using the RandomAttribute) or draw random values within your test (not as a parameter):

[Test]
[TestCase(15)]
[TestCase(38)]
[TestCase(2)]
[TestCase(72)]
[TestCase(69)]
public void RandomTest(int value)
{
    Assert.IsTrue(true);
}

Update

There is a known issue for this on github.

like image 89
Dio F Avatar answered Oct 26 '22 23:10

Dio F