2

I am using Visual Studio 2013, installed FsUnit 2.2.0, which requires NUnit 3.2.1 and FSharpCore 3.1. I created a separate test project and put a testfixture and test in there. My platform is x64 Win 10. The config is for 'AnyCPU' and 'Debug'. I've tried test settings for x86 and x64. When trying to build and create tests, I get:

------ Discover test started ------
NUnit Adapter 3.2.0.0: Test discovery starting
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\Users\Dad\Documents\Visual Studio 2013\Projects\...
Cannot run tests in process - a 32 bit process is required.
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\Users\Dad\Documents\Visual Studio 2013\Projects\...
Cannot run tests in process - a 32 bit process is required.
NUnit Adapter 3.2.0.0: Test discovery complete
========== Discover test finished: 0 found (0:00:00.1230077) ==========

If I change the config for both the test and target projects to 'x86' (instead of AnyCPU) then the error for the base project goes away, but the same thing happens for the test project.

No tests are ever discovered, help please ... and many thanks!

user1857742
  • 151
  • 2
  • 10

3 Answers3

4

You will need to remove nunit from your solution and install it again with "NUnit3TestAdapter", version 3.0.10 works.

Uninstall any NUnit software in add/remove program and in your solutions. Now using Nuget package manager (tools > NuGet Package Manager > Manage NuGet Packages for solution...) remove any NUnit you have in a solution and install older version (e.g. 3.0.1). Find "NUnit3TestAdapter" and install in version 3.0.10.

Thael
  • 41
  • 3
  • Not sure that I can roll back in VS 2013 ... I need nuget v3 to be able to issue the -version option, but the nuget CTP1 preview extension does not seem to be available anymore (http://blog.nuget.org/20140715/nuget-3.0-ctp1.html). I would like to install FsUnit v2.0.0 which uses NUnit 3.0 but I don't see how to do that. – user1857742 Jun 06 '16 at 20:58
  • Never mind, it worked to discover the unit tests again, but when I try to" run all" I get the same error... – cfl Jun 07 '16 at 06:34
  • I had to specify the CPU, from x86 to Any CPU. For some reason it changed to x86 when my Visual studio licence needed renewal – cfl Jun 08 '16 at 12:36
  • Thanks, since nuget in VS 2013 does not have version selection, what I did was to download the appropriate nuget version files (.nuget), setup a local nuget source for them to import them. I am using FsUnit 2.0.0; NUnit 3.0.1; Nunit 3.0 Test Adapter for VS2012 through 2015 version 3.0.8-ctp-8 [make sure to allow installs for 'include prerelease'] – user1857742 Jun 08 '16 at 23:53
2

I had the same problem with my .NET Core 2.0 project with NUnit 3.9 in Visual Studio 2017 and tests were not showing up in TestExplorer. Was stuck with this for quite some time. None of the solutions suggested in other related questions worked.

Then I figured out from this link that a class library with target .NET Standard does not work. The test project has to target .NET Core. Also, Microsoft.NET.Test.Sdk NuGet is required.

So, the steps are

  1. Make sure that the test project targets .NET Core
  2. Install latest NUnit NuGet (I used 3.9)
  3. Install corresponding NUnitAdapter NuGet (I used NUnit3Adapter)
  4. Install Microsoft.NET.Test.Sdk NuGet

Re-build and your tests will appear in Test Explorer in Visual Studio.


Note: Already added this answer to another .NET Core specific question. Adding here too, as the solution might be helpful in this scenario as well.

Arghya C
  • 9,805
  • 2
  • 47
  • 66
1

There is an error in NUnit 3.2.1 whereby the TestEngine assumes that it can't run a test requiring 32-bit execution in process. The assumption is always valid for NUnit's own runners, but not necessarily when the process is started by some other program. There's an issue filed about this.

Charlie
  • 12,928
  • 1
  • 27
  • 31
  • 1
    Can I downgrade to an earlier NUnit version? Or what would you suggest as a workaround? – user1857742 Jun 05 '16 at 15:11
  • I tried to downgrade, to multiple other versions, but still doesn't solve the issue. Any success there? – cfl Jun 06 '16 at 07:21
  • 1
    You don't need to downgrade your version of NUnit because the adapter contains it's own version of the engine and that's what it will use in any case. Just go back to the 3.0 adapter (3.0.10) if this is a continued issue for you. – Charlie Jun 06 '16 at 16:19
  • 1
    You can continue to use NUnit 3.2.1 for console runs, for example, which don't make use of the VS adapter. And the 3.0.1 engine (embedded in the 3.0.10 adapter) should be able to handle tests referencing the 3.2.1 framework. Of course, if you only work in Visual Studio using the adapter, it probably makes more sense to roll everything back as suggested in another answer. – Charlie Jun 06 '16 at 16:22
  • Thanks as well, when do you think the new NUnit will be available with this fix? – user1857742 Jun 08 '16 at 23:54
  • What is the issue number on github? – James John McGuire 'Jahmic' Jun 18 '16 at 12:47
  • That's issue #1548. It will be in the 3.4 release, next weekend. Sorry to take so long... SO just sent me the notice of the last comments. – Charlie Jun 19 '16 at 13:07