RhinoCommonUnitTesting icon indicating copy to clipboard operation
RhinoCommonUnitTesting copied to clipboard

Manual load of GH libraries when not using packages.config

Open marios-tsiliakos opened this issue 4 years ago • 7 comments

@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.

marios-tsiliakos avatar Jun 17 '21 14:06 marios-tsiliakos

Hi @marios-tsiliakos!

I also had this issue with the Grasshopper.dll.

Do I understand correctly, that to use your solution, the additional nuget package (Rhino.Inside) is necessary to be installed? Is there any other requirements?

paireks avatar Aug 24 '21 11:08 paireks

Hi @paireks , The current state of the master file is using the rhino.inside nuget package. So by using your tests should be executed fine and rhino loading properly. The Grasshopper.dll still needs need to be loaded manually. As vs cannot find it and load it from the build directory After doing some digging up I found that the reason for this is that in one f the previous PRs we switched to the new .csproj format-this "fails" to copy the GH dependencies in the build folder hence you have to manually load them into the test context. If you use the old project format the solution is working fine and you don't need to load anything - Rhino.Inside is taking care of that. https://github.com/marios-tsiliakos/RhinoCommonUnitTesting/blob/9f8569ec59a7d2101d5af3b7c6b4b19d20035ad8/Src/RhinoPlugin.Tests.RHInside/XunitTestFixtureRI.cs#L21

feel free to use the above if you don't migrate to the new format.

marios-tsiliakos avatar Aug 24 '21 12:08 marios-tsiliakos

Oh, ok now I see, I was using a version from 2020 when there was no Rhino.Inside required already, that's why I was confused :) Thank you for help! I will check it out once I will find some time ;)

paireks avatar Aug 24 '21 12:08 paireks

@marios-tsiliakos Would you be able to PR a fix or relevant documentation for this?

tmakin avatar Sep 21 '21 19:09 tmakin

@tmakin Sure. Will do later this week. I think the documentation is more important in this case but I will include a project using the old .csproj format that works as expected.

marios-tsiliakos avatar Sep 22 '21 19:09 marios-tsiliakos

Yeah, some documentation will help a lot. I just tried new fixture but couldn't get it to work, but I guess it's because I'm missing something. Should it work also for multiple test classes?

paireks avatar Sep 23 '21 07:09 paireks

@paireks yes it works with multiple test classes. They just have to be decorated with the same/correct test collection attribute.

marios-tsiliakos avatar Sep 23 '21 13:09 marios-tsiliakos