Not sure if anyone has figured out how to do unit tests for RhinoObject.
One of main reason that I want to do this is because I want to keep tracking of RhinoObject ID, and now I have to test it manually in Rhino App.
It’d be much appreciated if anyone could provide any insight.
Our NUnit workflow is not a polished process, is not automated, and covers a only subset of our code base. Test fixtures are in assemblies and a plug-in command launches a runner (provided by @curtisw) from which you can load and run your tests.
it still seems like you are doing integration testing with a unit test framework. I think you don‘t need to test if creating or retreiving information from a RhinoObject works since this part of your software is not of your domain. You can expect it to work properly. Only testing your own code base in a very singular manner is a unit test. And this should be feasible within Visual Studio directly.
Thanks, yes, I have a part of unit tests related to geometry are tested within Visual Studio directly. But I also have parts like parallel processing geometry with UserData attached. It has to be tested in Rhino, and I wouldn’t find out this crashes Rhino every time if I didn’t test it in Rhino. This is just simply that Rhino doc is monitoring each UserData across the entire document, and it cannot be accessed/duplicated by multiple threads.
These two weeks, I have been experiencing 3 Rhino bugs already (one of which has been reported by other 4 years ago, but still hasn’t been fixed), and I cannot expect Rhino will work with UserData properly without testing.
Rhino has been giving me a lot of surprises lately.
This is my ultimate goal to have all my code tested without opening Rhino.
If you modify and sometimes access not-threadsafe objects from another thread chances are high to break something. Even worse, sometimes it works, sometimes not.
I would always(!) invoke a change a RhinoObject within Rhinos Main Thread. I never encountered any issues with Rhino Objects, nor by adding, reading or modifing data within its thread. But I could be wrong.
Further more I don’t know if its helpful to test interaction with Rhino Objects in any of your Commands/Components.
If you wrap your interaction with RhinoObjects away from your codebase you can isolate this special case and test the rest totally isolated. You can even mock this RhinoObject-interaction then. This is what you usually do for untestable piece of code within an application.
Sometimes code is also written untestable. So if you like to test it, you maybe need to change the implementation as well, but I’m still not sure if invoking Unittesting within Rhino is the solution here.
I think the main part of reason that I have to test some of unit tests within Rhino is because the Geometry’s UserData can only be accessed when Rhino doc exists (@dale please correct me, I might be wrong, but this is what I am experiencing).
The main part of my code is dealing with geometry’s UserData. Not directly testing on RhinoObject, but RhinoObject is an indication of Rhino doc’s presence.