Reputation: 10974
xUnit tests run under Jenkins.
I run tests for x86/x64 Debug/Release configurations. Some configuration fails with error when running under Jenkins.
Run command and error message follows:
packages\xunit.runner.console.2.1.0\tools\xunit.console.exe bin\x86\Release\MyDllName.dll -verbose -parallel none -diagnostics
xUnit.net Console Runner (64-bit .NET 4.0.30319.42000)
System.BadImageFormatException: Could not load file or assembly 'MyDllName, Version=1.3.549.4300, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
<Absolute-path-to-file>\RunTests.1.proj(59,5): error MSB3073: The command "packages\xunit.runner.console.2.1.0\tools\xunit.console.exe bin\x86\Release\MyDllName.dll -verbose -parallel none -diagnostics" exited with code 1.
When I run the same batch file from command line as I use to run Jenkins job, everything work fine.
I tried to run Jenkins as service and as standalone application. I got error in both cases.
I tried to run ILSpy
on this dll and did not found some error messages concerning missing dependencies.
How to make xUnit
run successfully on all configurations under Jenkins?
My dll built with .NET 4.6.1.
Jenkins version: 2.32.1, but I have the same issues with older versions.
Server OS: Windows 2008 R2 Enterprise.
xunit.runner.console: 2.1.0
Upvotes: 2
Views: 676
Reputation: 61885
This is likely the result of the DLL in question having a 32-bit bittedness constraint.
You'll need to either
a. run the 32-bit runner (if for example some dep requires a 32 bit DLL) by using dotnet xunit -x86
command,
or
b. build the test assembly for AnyCpu [or x64] (but using the "Prefer 32 bit" flag). Keep in mind the flag is available only in .NET 4.5, not in 4.6.
See lots more similar cases in this answer
Upvotes: 2