Unit testing - Run unit tests without running Rhino.exe


#1

Hi,
I have a C# solution that contains:

  • 1 Rhino plugin project
  • 1 class library project
  • 1 unit test project

I would like to perform unit tests on my class library implementation that contains references to RhinoCommon.dll such as Vector3d and Mesh. When I tried to run the unit tests, I encountered error: “System.IO.FileNotFoundException: Could not load file or assembly ‘RhinoCommon, Version=5.1.30000.16, Culture=neutral, PublicKeyToken=552281e97c755530’ or one of its dependencies. The system cannot find the file specified.”

I found some discussion about issues of running unit tests without running Rhino.exe due to dependencies of RhinoCommon.dll on Rhino.exe. But most of the discussions happened a few years ago.

I would like to check if such dependencies still valid and is there any solution to this issue?

Thank you.

PS: the version of RhinoCommon that I am currently using is 5.1


#2

I have just put together an example repo of how this can be done using the latest WIP 7 release:

However if you are stuck with v5 you could try the steps described here:

Another option would be to try and run your tests from within Rhino using NUnit. See example repo here:


#3

Regarding the assembly not found issue you try the assembly resolve approach I’ve used here:

Look for the line AppDomain.CurrentDomain.AssemblyResolve += ResolveRhinoCommon


#4

Thank you very much for the swift response.
I will try out the v5 steps.
As I planned to run the unit tests during the CI build, running the tests from within Rhino is not an option.


#5

I had followed the steps in post. I no longer encounter error: “System.IO.FileNotFoundException: Could not load file or assembly ‘RhinoCommon, Version=5.1.30000.16, Culture=neutral, PublicKeyToken=552281e97c755530’ or one of its dependencies. The system cannot find the file specified.”

GeometryTests.cs (1.8 KB)

Unit test: CheckVector passed
However, unit test CheckBooleanUnion does not return. I had to manually kill the vstest.executionengine.x86.exe process in the end.


#6

OK, first off CheckVector is probably not calling though to the native rhino DLL. As you are simply initialising a CLR (.NET) type and then checking its value. So I doubt that is fair test. I suggest you call Unitize() on your vector as that references the native stuff. See source here:

Let me know how that goes and then we can revisit the CheckBooleanUnion issue.


#7

I experienced the same issue after I added a line in CheckVector:

v.Unitize();

Below are some information that I gathered from the Dump:

|Exception Code:|0xC0000005|
|Exception Information:|The thread tried to read from or write to a virtual address for which it does not have the appropriate access.|


#8

I’ve just tried to run a basic test against Rhino 5 and I can’t get x86 working at all. I can get the 64 bit version to run intermittently, but I’m also getting memory access violations. It used to work in the past, but who knows what has changed since then. Windows updates, VS updates, MS Test updates, Rhino Updates etc.

So in summary I would suggest you abandon your CI integration for Rhino 5 as it is too fragile.Your time is probably better spent elsewhere. I understand just how much time this stuff can soak up. I learnt recently that even McNeel themselves don’t run unit tests as part of their CI. Instead they run the tests manually every now and again.

It is worth noting that you can probably run 95% of your v5 code against they latest WIP v7 without any changes at all. That is probably your best bet if you really need CI integration. To get access to v7 you just need a single v6 license. https://www.rhino3d.com/download/rhino/wip


#9

Thank you very much for your time in verifying my findings and also your suggestion.
With all this information, I will be able to make a better conclusion and decision.:smiley: