running nunit tests (x86) with gallio - nunit

I am trying to run nunit tests with gallio.
These tests run with nunit-console-x86.exe
When I run them with nunit-console.exe, I am getting System.BadImageFormatException
Running with Gallio.Echo.exe (installed the x86 bundle from gallio.org), I am getting the same exception. Is there a way to get gallio to use the nunit-console-x86.exe?
I am running the command "C:\Program Files (x86)\Gallio\bin\Gallio.echo.exe" /r:IsolatedProcess "C:\projectdata.Tests.dll"
and I am getting this exception:
Message
System.BadImageFormatException : Could not load file or assembly 'projectdata, Version=8.2.0.17, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Update: I figured out this is because I have project.dll(x86) and project.test.dll(Any CPU).
Any Ideas on how I can get gallio.echo to work for this? Is it possible to get a Gallio.Echo-x86.exe?

I was able to get it working by renaming the following files.
Gallio.Host.Elevated.exe --> Gallio.Host.Elevated.old.exe
Gallio.Host.Elevated.x86.exe --> Gallio.Host.Elevated.exe
Gallio.Host.exe --> Gallio.Host.old.exe
Gallio.Host.x86.exe --> Gallio.Host.exe
Note: You may want to create another copy of the gallio folder under program files to do this.
I have 2 copies. one in Program Files and one in Program Files (x86) with these changes.

Related

NUnit components for version 4.0.30319 of the CLR are not installed

I am trying to implement an automated build process. After the build, the unit tests on nunit-console.exe are run. The following error is displayed:
> c:\nunit_2.5.10\nunit-console.exe c:\builds\Output\bin\TDD.nunit /framework=4.0.30319 /nologo /trace=Off
ProcessModel: Default DomainUsage: Default
Execution Runtime: v4.0.30319
Unhandled Exception:
System.ArgumentException: NUnit components for version 4.0.30319 of the CLR are not installed
Parameter name: targetRuntime
at NUnit.Util.TestAgency.LaunchAgentProcess(RuntimeFramework targetRuntime, Boolean enableDebug)
at NUnit.Util.TestAgency.CreateRemoteAgent(RuntimeFramework framework, Int32 waitTime, Boolean enableDebug)
at NUnit.Util.TestAgency.GetAgent(RuntimeFramework framework, Int32 waitTime, Boolean enableDebug)
at NUnit.Util.ProcessRunner.Load(TestPackage package)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
There is no nunit-agent.exe on the build machine. However, on my machine it is not even called, so I suppose it is not necessary.
Why is nunit-agent.exe required in some cases but not always required? What conditions should be satisfied so nunit-agent would not need to launch?
Edit: I have found one resource, which kind of describes how it works, but not quite well: http://www.nunit.org/index.php?p=nunit-agent&r=2.5.10. It says that it is launched when program needs to run under a different framework than the one being used by NUnit (which is the case, since NUnit is compiled for 2.0). However, on my machine the nunit-agent.exe does not run although conditions seem to be the same.
I ran into this same error and it was definitely solved by including nunit-agent.exe in the folder where nunit-console.exe was launched. The complete list of .exes and .dlls necessary to run a test successfully was:
nunit.core.dll
nunit.core.interfaces.dll
nunit.framework.dll
nunit.util.dll
nunit-agent.exe
nunit-console.exe
nunit-console-runner.dll
All files are packaged in the download available from nunit.org. As of this post, 2.6.3 is the current version. Documentation for the console runner can be found here. And the direct download for the zip file is here.
For a test assembly targeting .NET 4.5.1, the following statement will execute tests:
nunit-console.exe your-assembly.dll /framework=v4.5.1
Adding a "startup/supportedRuntime" configuration tag to nunit-console.exe.config solved it for me.
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319" />
</startup>
Try using Fusion to see what assembly might be missing and where the .exe is looking.
http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx

Teamcity not DLL's for some NUnit Test projects

I get this error when running my Moq tests through Teamcity 5
Test(s) failed.
System.IO.FileNotFoundException :
Could not load file or assembly 'Moq,
Version=3.1.416.3, Culture=neutral,
PublicKeyToken=69f491c39445e920' or
one of its dependencies. The system
cannot find the file specified. at
MyCode.Tests.SomeHandlerTests.Setup()
The tests run fine on my local; they just fail on the build server.
I made sure the assemblies are in the Bin (looking at them now over RDP just be double sure).
So the issue was to do with the Test DLL search path under the nunit settings
It was:
..\Tests\**\*Test*.dll
But is now:
..\Tests\*\bin\Debug\*Test*.dll
And things work nicely
UPDATE
http://confluence.jetbrains.com/display/TCD8/NUnit
You can use this pattern
**\*.dll
as long as you add this pattern in the "Do not run tests from" field
**\obj\**\*.dll
I had a similar issue, but found that I had different version's of Moq between my 2 Test projects.
The issue that I had was that the correct version was not available.
Just do
Update-Package Moq
From the Package Manager command line

How to copy/install assembly in a GAC? (Some problem running NUnit)

I have NUnit installed at this directory.
C:\Program Files\NUnit 2.5.5\bin\net-2.0
I made the directory beneath a GAC.
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\NUnit
and copied the nunit.framework.dll, but I got the same error.
When I try to run my unit test (mut.dll) in some random directory. I get the following error. I have to copy the mut.dll under the NUnit directory in order to run it.
ProcessModel: Default DomainUsage: Single
Execution Runtime: net-2.0
Could not load file or assembly 'nunit.framework, Version=2.5.5.10112, Culture=n
eutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The system
cannot find the file specified.
What went wrong? How can I install/copy the assembly inside a GAC?
You could add the NUnit directory to your PATH environment variable, that might take care of it.
Otherwise, check out this stack overflow post for other ideas.

NUnit-console 2.5.4 not capable of running multiple assemblies?

I am having problems running tests with the command line NUnit test runner.
I am using version 2.5.4 with .NET 4 on an x64 machine.
Using the following line results in a failure "Could not load file or assembly 'bar' or one of
its dependencies. The system cannot find the file specified."
nunit-console-x86 foo.dll bar.dll /framework=4.0.30319
If I reverse the dll file names it complains about not finding 'foo' instead...
It works if I run them separately like:
nunit-console-x86 foo.dll /framework=4.0.30319
Also the tests of the second file works if I run:
nunit-console-x86 bar.dll /framework=4.0.30319
Before upgrading our projects to 4.0 we used NUnit 2.5.2 and the same command line tool options and at that point the runner worked well with multiple assemblies. It seems like the ability to run tests on multiple files at the same time is broken...
Anyone that can see the same behavior or does it work indicating that my environment is somehow broken?
/Per
Assembly loading behaviour has changed between 2.5.4 and 2.5.3. It was causing problems for us, so we reverted to 2.5.3, since that still supports the 4.0 framework.
We use nunit-console.exe 2.5.3 with multiple assemblies in our msbuild script, which looks like this:
<Exec Command="%22$(NUnit_Install_Directory)bin\net-2.0\nunit-console.exe%22
/noshadow #(TestableAssemblies, ' ') /xml $(BuildFilesPath)\NUnit-Results.xml" />
On execution, it fills out like this (edited for readability):
"c:\Program Files\NUnit 2.5.3\bin\net-2.0\nunit-console.exe" /noshadow D:\BuildAgent\GojiSoft.Application.Test\bin\Release\GojiSoft.Application.Test.dll D:\BuildAgent\GojiSoft.Common.Test\bin\Release\GojiSoft.Common.Test.dll
/xml D:\BuildAgent\work\2f016459feee51ce\Build\NUnit-Results.xml
We don't use a 64bit machine for our unit tests, so YMMV.
I have a blog post about the addtional modification your should make to the nunit-console-x86.exe.config here: Getting .Net 4.0, Team City, MSBuild and Nunit to play nice.
I has the same problem. I got around it by creating an nunit project in the GUI that includes multiple dlls. Then I can run it with nunit-console.

NUnit assembly not found

I've used NUnit before, but not in a while, and never on this machine. I unzipped version 2.4.8 under Program Files, and I keep getting this error when trying to load my tests.
Could not load file or assembly 'nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The system cannot find the file specified**
In order to simplify the problem, I've compiled the most basic possible test file.
using NUnit.Framework;
namespace test
{
[TestFixture]
public class Tester
{
[Test]
public void ATest()
{
Assert.IsTrue(false, "At least the test ran!");
}
}
}
I've added "C:\Program Files\NUnit-2.4.8-net-2.0\bin" to my PATH (and rebooted). Note that if I copy the test assembly into that folder, then
C:\Program Files\NUnit-2.4.8-net-2.0\bin>nunit-console test.dll
works, but
C:\Program Files\NUnit-2.4.8-net-2.0\bin>nunit-console c:\dev\nunit_test\test.dll
and
C:\dev\nunit_test>nunit_console test.dll
fail with the above error.
Presumably I could get around this by copying the NUnit.Framework DLL file into my project's bin folder, but I don't remember having to do this in the past. Moreover, I get the same error in the GUI. Shouldn't the GUI know where the framework is located (that is, in the same folder)?
I'm not using Visual Studio. I use the following line to compile the test project.
%windir%\Microsoft.NET\Framework\v2.0.50727\csc.exe /r:"C:\Program Files\NUnit-2.4.8-net-2.0\bin\nunit.framework.dll" /t:library /out:test.dll test.cs
I tried both the .msi and the .zip file with the same result.
Make sure you have added a reference to nunit.framework. If you have, then make sure the properties of that reference have the copy local property set to true.
I had the same problem, and I had installed using NUnit-2.4.8-net-2.0.msi. Expanding on the "add to the GAC" comment, here's what I did:
Open your "Visual Studio command prompt (generally: make sure gacutil is in your path) and: cd "C:\Program Files\NUnit 2.4.8\bin"
Unregister your NUnit entries from the GAC. You can do this by finding the NUnit entries registered in the GAC:
gacutil /l | find /i "nunit" > temp.bat && notepad temp.bat
Prepend the nunit.core and nunit.framework lines with "gacutil /uf", i.e.:
gacutil /uf nunit.core,Version=2.4.2.0,Culture=neutral,PublicKeyToken=96d09a1eb7f44a77
gacutil /uf nunit.framework,Version=2.4.2.0,Culture=neutral,PublicKeyToken=96d09a1eb7f44a77
Run your .bat file to remove them:
temp.bat
Register the NUnit DLL files you need:
gacutil /i nunit.core.dll
gacutil /i nunit.framework.dll
If you install using NUnit-2.4.8-net-2.0.msi, the NUnit assemblies are added to the GAC.
You can also reinstall manually by running gacutil from the Visual Studio 2005 command prompt.
Note that the current NUnit installation (2.5.10) doesn't register itself automatically in the GAC.
If you must use GAC, register it via gacutil /i <nunitframeworkpath> where nunitframeworkpath is usually %Program Files%\NUnit\net-2.0\framework\nunit-framework.
I got this error message today when I tried to add a new test assembly to an existing NUnit test project. It seems that my test projects had multiple path references to identical nunit.framework.dll assemblies.
If you have more than one test assembly in your NUnit project, you may want to verify the Path property of the nunit.framework reference in your test projects. Once I made them match, the error message went away.