I was looking into the Dynamo testing posibilities to see what I could create to test the Dynamo package that I’ve been working on (specifically at How to write tests for a package).
When I create my own test assembly the tests don’t run at all. I get a message saying “Test run finished in … ms. 0 Total tests - 0 Passed, 0 Failed, 0 Skipped”
When using the assembly ‘SampleLibraryTests’, all tests fail, with error messages like this:
PassingTest
Duration: 845 ms
Message:
System.NotImplementedException : Method ‘SetAttributes’ in type ‘Autodesk.LibG.CurveHost’ from assembly ‘LibG.ProtoInterface, Version=2.9.0.3355, Culture=neutral, PublicKeyToken=null’ does not have an implementation.
Stack Trace:
HostFactory.get_Factory()
Point.ByCoordinates(Double x, Double y, Double z)
HelloDynamoZeroTouchTests.PassingTest() line 46
Is anyone able to help? Perhaps there is an updated version of the testing page on Gitbook?
Thanks if anyone can help! It is much appreciated.
SetAttributes is a new internal api - I don’t believe it is in anything released (I think the error basically means the version of the geometry library that is being loaded during the test doesn’t have this method, we’ve only seen this error in our dev builds - so are you using a 2.11 or 2.12 daily build of dynamo?
I would try to get a later one - or perhaps one of the stable builds.
also - for the test nugets
Make sure the version of SampleLibraryTests matches your dynamo version closely ie use 2.x which matches your 2.x version of Dynamo.
PassingTest
Duration: 718 ms
Message:
System.NotImplementedException : Method 'SetAttributes' in type 'Autodesk.LibG.CurveHost' from assembly 'LibG.ProtoInterface, Version=2.8.0.2374, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Stack Trace:
HostFactory.get_Factory()
Point.ByCoordinates(Double x, Double y, Double z)
HelloDynamoZeroTouchTests.PassingTest() line 46
I checked out the LibG.ProtoInterface assembly that is installed in the Dynamo folder and it doesn’t contain a method called SetAttributes. Could this be the issue? I’m not sure, I have no with unit testing at all…
Could anything else be the problem or could I be missing something?
I have a couple of different Dynamo versions (2.1, 2.4, 2.8, 2.9 and 2.10) that all work well (including geometry creation). I use them to test my package whenever there is a big update.
Will check if the folder location is an issue today. I have Revit versions 2019, 2020 and 2021 installed atm.
I didn’t have 7zip so I used Powershell to unblock all files:
Get-ChildItem -Path ' path here ' -Recurse | Unblock-File
Could that make a difference? Will update later today, thanks again!
We recently found a bug in the geometry library lookup that the geometric test base (and sandbox) use - another thing you can try is to use the latest pre release 2.12 nugets where the bug should be fixed.
I don’t think the powershell unblock would cause an issue, it’s just harder to get right
Running Dynamo from another folder didn’t help, neither did getting the beta nugets unfortunately.
I managed to get a step further with my own test assembly though (I had set nunit.framework to copy local = false by accident), or at least I get another error message than before. Does this shed any light on what the problem might be?
PassingTest
Source: Class1.cs line 19
Duration: 4,2 sec
Message:
SetUp : System.TypeInitializationException : The type initializer for 'Autodesk.DesignScript.Geometry.HostFactory' threw an exception.
----> System.IO.FileNotFoundException : Could not load file or assembly 'LibG.Interface, Version=2.11.0.4226, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Stack Trace:
HostFactory.get_Instance()
IExtensionApplication.OnBeginExecution(IExecutionSession session)
GeometricTestBase.Setup()
--FileNotFoundException
HostFactory.ctor()
HostFactory.cctor()