Support for Nunit for Plugin development

Support for Nunit for Plugin development

soonhui
Advisor Advisor
2,059 Views
4 Replies
Message 1 of 5

Support for Nunit for Plugin development

soonhui
Advisor
Advisor

I've developed Autodesk plugins and now I want to test the functionalities using automated tests. And I want to do it from Nunit/Console environment.

 

I understand that you do allow batch script automation.  But this is a poor fit for my purpose because it's just a batch script and thus is impossible to direct manipulate .Net objects. It just makes my testing effort difficult if not impossible. So much so that I won't find the time well-spent.  

 

To do unit testing under current AutoCAD constraints, I can wrap my tests in Commands, and the Netload my dll and call the Commands from the batch script. But the batch script can't handle dialog boxes that require user interaction like 'Yes' or 'No' reply. So how can I proceed then?

 

Secondly, I need to invent my own Assert statement and find a way to interpret it. I also can't make use of the test results aggregation and analytics tools such as NUnit Test Adapter to view my test results.  I will have to write my own test adapters. These are a huge waste of development time because such a tool/convention already exists and is mature. Why reinvent the wheel?

 

If you allow me to write my test code in Nunit ( and run it successfully), then I can leverage all the standard code development best practices like mocking and MVVM so that I'll get the best automated testing experience. This is important if we want to develop a robust software.  

 

Solution: I've written up a full solution here

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Accepted solutions (1)
2,060 Views
4 Replies
Replies (4)
Message 2 of 5

Ed__Jobe
Mentor
Mentor

I found these pages for you that might help.

https://forums.autodesk.com/t5/net/how-to-create-unit-testing-for-autocad-add-in/td-p/10724527

https://www.keanw.com/2013/09/au-2013-class-schedule-preview.html - I was unable to find the class at AU online.

https://www.autodesk.com/autodesk-university/class/Automate-Your-Revit-Add-Testing-Unit-Testing-2019

 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 5

soonhui
Advisor
Advisor

Thanks @Ed__Jobe !

 

There are no native support for Civil 3D test framework, though one can write one based on RevitTestFramework and CADtest. But I expect many months of developer effort on this. And no guarantee that it will work because the underlying architecture of Revit and Civil 3D can be different. For CADbloke's CADtest I tested on Civil 3D 2023 and it seems to work! Now it's time to see how far it can carry me through.

 

Anyway, since these are just community effort, there is no guarantee that the above framework will always work with future versions. Autodesk should really provide or at least maintain the test frameworks for plugin development ( Autodesk can take a cue from Microsoft by making these frameworks open sourced). This is what engaging community is all about. 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 4 of 5

soonhui
Advisor
Advisor

Here's a good reason why Autodesk must own this effort.

 

As I tried to use the tool, there were just too many hiccups, undocumented behaviors and even bugs along the way. Often I can't tell which from which. Just take a look at the following issues and try to tell me whether they are due to my (mis)use of AutoCAD API, or due to bugs in AutoCAD itself:

 

  1. https://forums.autodesk.com/t5/civil-3d-customization/side-loading-database-won-t-populate-civilappl...
  2. https://forums.autodesk.com/t5/civil-3d-customization/tinsurface-rebuild-crashes-the-whole-civil-3d-...
  3. https://forums.autodesk.com/t5/net/running-accoreconsole-exe-with-nunitlite-will-cause/td-p/11407512

I bet no one can, maybe except Autodesk developers, which who don't seem to frequent the forum. OK Autodesk does have paid employees patrolling the forums but they are community managers who are not technical enough to handle the so many issues here. We have to fend off for ourselves!

 

At the very least, Autodesk should start with answering issues in the forum seriously without relying on unpaid volunteers. 

 

 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 5 of 5

soonhui
Advisor
Advisor
Accepted solution

A complete solution can be found here

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D