Code Monkey home page Code Monkey logo

rhinocommonunittesting's Introduction

RhinoCommon Unit Testing

Intro

Example of unit testing RhinoCommon from within the Visual Studio test runner on windows.

Prerequisites

Rhino 7
https://www.rhino3d.com/download/Rhino/7.0

Visual Studio 2019 https://www.visualstudio.com/downloads/

Test Framework

This project provides examples for XUnit and MS Test, but the principles would be easily transferable to other frameworks if needs.

How to Run

  • Build the solution
  • Test should appear in Visual Studio Test Explorer
  • Set test enviroment to x64
    Test > Test Settings > Default Processor Architecture > x64
  • Click Run All to run the tests

Further Reading

For more info on using Rhino in a headless environment see the Rhino Compute project: https://github.com/mcneel/compute.rhino3d

Troubleshooting

  • Note that when Rhino is in headless mode there is no document defined. The static property RhinoDoc.ActiveDoc will thus be null which may trip up your plugin code.

  • If you have any problems getting this to work or you have a more complex use case, then please get in touch via the issue tracker.

rhinocommonunittesting's People

Contributors

marios-tsiliakos avatar paireks avatar tmakin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rhinocommonunittesting's Issues

TestInitialize method

Hi guys,

Firstly thanks for this project templates, they helped already a lot!

When I want to initialize Point3d objects in constructor to use them in different tests, somehow I can not run tests.. Do you know why?

Best regards,

  • Oğuzhan

CI

@tmakin @marios-tsiliakos ,

Thanks for this template.

In the XUnitTestFixture, I see that you are using the locally installed Rhino. If I were to follow this template to run tests on a CI pipeline, I am assuming I will need to use Rhino Compute. Is that correct?

Manual load of GH libraries when not using packages.config

@tmakin I think I figured out why we need to manually load the Grasshopper.dll even though Rhino.Inside should load it by default.
I audited where the assemblies are loaded from and it seems that Rhino.Inside looks for them in the bin folder when it runs the tests. Without using a package.config file - with the new .csproj format - these are not copied in the build directory, so our tests fail to load them.
I added a new project using the old format rhino.inside loads everything fine.
https://github.com/marios-tsiliakos/RhinoCommonUnitTesting/blob/9f8569ec59a7d2101d5af3b7c6b4b19d20035ad8/Src/RhinoPlugin.Tests.RHInside/XunitTestFixtureRI.cs#L21-L39
Also when I tried to run the Xunit tests again and the GH one was failing because GH_IO.dll wasn't loaded so fixed that here:
https://github.com/marios-tsiliakos/RhinoCommonUnitTesting/blob/9f8569ec59a7d2101d5af3b7c6b4b19d20035ad8/Src/RhinoPlugin.Tests.Xunit/XunitTestFixture.cs#L65-L86
Let me know if you want to address any of these in a formal PR.

Curve.Offset() fails to run in all tests

Discussing it here too.

When any version of the method is called, Curve.Offset() doesn't complete and throws "Object reference not set to an instance of an object."

Edit: To clarify, this might not be an issue because of this project, but it's directly related.

Updating RhinoCommon/Grasshopper to v7 causes System.IO.FileNotFoundException

If I clone the project freshly and upgrade from the existing versions of GH/Rhino to the latest pre-release, The GHBox_Centroid_ReturnsGHPoint Test will return the following error:

System.IO.FileNotFoundException : Could not load file or assembly 'Grasshopper, Version=7.0.20168.13070, Culture=neutral, PublicKeyToken=dda4f5ec2cd80803' or one of its dependencies. The system cannot find the file specified.
Stack Trace:
XunitExampleTests.GHBox_Centroid_ReturnsGHPoint()

I've checked my local .nuget folder and this has the package in. I have no other issues with other projects using this package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.