Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using xUnit.net Console Runner With Mono

This seems like "too easy" of a subject for a question on here, but I'm honestly having a hard time finding any information on the subject.

Basically, here's the gist. We have a couple projects across different platforms (Windows and Mac, for instance) written in C#. We use xUnit for our unit tests via xUnit.net, which are shared between the platforms. I'm trying to get these tests to run in the xUnit.net console runner, as described here, but I can't seem to get the runner to work in mono. Is there something extra I need to do? The following is what I'm trying to do via command line:

 mono [REPOSITORY_PATH]/Apple/Source/Solutions/packages/xunit.runner.console.2.1.0/tools/xunit.console.exe "[REPOSITORY_PATH]/Apple/Source/Platform/Mac/MacXunitTests/bin/Debug/[PROJECT_NAME].Tests.Mac.dll"

The following is the error I received:

 xUnit.net Console Runner (32-bit .NET 4.0.30319.17020)
 Can't find custom attr constructor image: /private/var/folders/0p/s4d1k4150zd2v8b0y1q2nz902v4jm6/T/d724bcb6-cce1-4430-b645-6dadd980c2ee/d724bcb6-cce1-4430-b645-6dadd980c2ee/assembly/shadow/6755efca/b6f5411e_d1a0aed4_00000002/xunit.execution.desktop.dll mtoken: 0x0a000009
 Unhandled loader error: 7, (null) xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c Xunit.Sdk.PlatformSpecificAssemblyAttribute
 * Assertion: should not be reached at loader.c:298
like image 830
Jyosua Avatar asked Aug 11 '26 23:08

Jyosua


1 Answers

As it turns out, this is a result of using an older version of xUnit.net. We were using some kind of release candidate version of 2.0, which was causing the error I posted. Removing the nuget package and reinstalling 2.0 seems to make the tests runnable.

I've now discovered that the tests are failing in the console runner, but this appears to be related to some error loading an assembly in a collection fixture, but this is outside the purview of the original question.

like image 118
Jyosua Avatar answered Aug 13 '26 12:08

Jyosua



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!