1
votes

I'm having some trouble running my tests from command line. I have a separate project for the tests and usually using Rider where the tests run flawlessly. However, I want to run them in a CI environment and therefore need to be able to run them form command line.

I'm trying to run Projectname>"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" Test\Test.csproj NUnit Console Runner 3.4.0 Copyright (C) 2016 Charlie Poole

Runtime Environment
   OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
  CLR Version: 4.0.30319.42000

Test Files
    Test\Test.csproj

Errors and Failures

1) Error : Test.MVCmodel.CoilClassTest.CoilCreateEmptyIdTest
System.BadImageFormatException : Could not load file or assembly 'UserInterface, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
   at Test.MVCmodel.CoilClassTest.CoilCreateEmptyIdTest()

The same thing happens when running "C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" Test\bin\Debug\Test.dll

The Test Project is located inside the MainProject: Projectname\Projectname.csproj and Projectname\Test\Test.csproj

And yes, I have found quite a few posts similar on Stackoverflow, but I found no applicable solution.

1
32-bit process vs. 64-bit process almost certainly. Make sure your application and test project is compiled for the right type of target.Lasse V. Karlsen
Agreed. This is normally auto-detected by nunit - you're using quite an old version of the nunit console - I'd recommend trying the latest version.Chris
Ah - I missed you're passing the csproj in instead of the assembly. That may also affect what is automatically recognised. There's an --x86 flag, if you need to force x86Chris
Yes, thank you, the --86 flag did it. It seems I also had different versions of nunit for my main project and my Test project....timedistance

1 Answers

0
votes

This solved the problem for me. Under build settings change the platform target to x86

enter image description here

This of course is assuming that UserInterface exists and runs well outside of the CLI environment (like in visual studio)