Unit testing plug-in code with NUnit


(Alain Cormier) #1

Continuing the discussion from How to test at runtime if my dll is running inside Rhino or not?:

Hi menno,
Interesting way to run NUnit. I’m loading NUnit from a plug-in command and it works ok.


Unit testing - Run unit tests without running Rhino.exe
(Menno Deij - van Rijswijk) #2

In my case I don’t need to have rhino running, it speeds up the test-implement cycle. We also created a plugin specific to running test code from within rhino, probably similar to what you are describing.


(Alain Cormier) #3

Sounds good. I might give that a try. I was thinking of trying resharper.


(Menno Deij - van Rijswijk) #4

You wouldn’t absolutely need ReSharper for this; running a test assembly in the NUnit test GUI will also work if you put RhinoCommon.dll and its dependencies in the same folder. I can give you a complete list of dependencies if you want - I have to check it on Monday though.

But, that does require switching back & forth between VS and the NUnit test runner; ReSharper integration is all inside VS.


(Alain Cormier) #5

I want to try resharper anyway so I’ll go that route. Yes, if you can give me the list that would be great.
Thanks


(Menno Deij - van Rijswijk) #6

ReSharper is a great product that is worth the investment. The refactoring stuff they have is great, and all kinds of nice keyboard shortcuts (Alt+Enter is the one I use hundreds of times a day), code style checking, LINQ suggestions, etc. etc. Takes some getting into, but I couldn’t work without it.


(Menno Deij - van Rijswijk) #7

In C:\Program Files\Rhinoceros 5.0\System select these 9 files and copy them to the output folder where your plug-in and/or DLLs are. Note that you need to remove Rhino_DotNet and RhinoCommon prior to debugging in Rhino - otherwise your plug-in won’t load (you get an error message).

Ltdis15x.dll
Ltfil15x.dll
Ltkrn15x.dll
openNURBSx64.dll
rhcommon_c.dll
Rhino.exe
Rhino_DotNet.dll
RhinoCommon.dll
tlx64.dll

For the 32-bit version of Rhino, the files that have x64 in them, will be named differently.


Mysterious System.BadImageFormatException Error using MS test on VS Express 2013 when trying to create unit tests for a Grasshoppper plugin
(Alain Cormier) #8

Great! I’ll give that a try. Thanks a lot.


#9

Hi @menno, Have you managed to get this working with Rhino 6? I’ve tried copying resources to my test directory and adding Rhino System dir to my path. I’ve also tried test architecture as x64 as that worked for me in the past with Rhino 5.

The exception I’m getting is: Unable to load DLL 'rhcommon_c': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)


(Menno Deij - van Rijswijk) #10

I haven’t tried with Rhino6 yet, we’re planning to migrate to v6 towards the end of the year.

I’m quite sure that this method of doing unit testing is not supported by McNeel, and that the testing of more complex geometric routines will never work (and did not work in Rhino5) because of licensing issues.


#11

Cool, thanks. I will post back here if I do figure it out.