running unit-tests with Revit offline

running unit-tests with Revit offline

avpBS7DE
Contributor Contributor
577 Views
4 Replies
Message 1 of 5

running unit-tests with Revit offline

avpBS7DE
Contributor
Contributor

Hello,

Similar question to this.  I have Revit 2021 API. I run unit-tests from a PushButton of an External Application. The disadvantage is that Revit my be on all the time to do this. I have used NUnit and built against the proper C:\ProgramFiles\Autodesk\Revit 2021\RevitAPI.dll, or against the stub dll from this chap.

I would like to run my unit-tests from outside of Revit, possibly from within VS with MSBuild, or command line with dotnet test. Is it possible ?

Thank you

0 Likes
578 Views
4 Replies
Replies (4)
Message 2 of 5

perry.swoboda
Advocate
Advocate

This depends on what you are defining as a unit test.  A true unit test does not depend on anything else and its inputs and outputs can be mocked or stubbed out.  You can run these anywhere.

However, if you are like me, your unit tests are actually integration tests, and require interaction from the Revit API.  Like you need to know the the code that adds a wall to a Revit file actually adds it to the correct spot.
For that we use RevitTestFramework.  It has an NUnit style for writing the test, but the test is run in a specific runner that starts Revit to run the test.  
https://github.com/DynamoDS/RevitTestFramework

I had to recompile it with Revit 2021 files in order for it to work for Revit 2021.

0 Likes
Message 3 of 5

jonathan.taVCBM2
Enthusiast
Enthusiast

Hi @perry.swoboda ,

I was trying to get the RevitTestFrameWork to work with Revit 2023 .
It seemed to compile ok (swapped the Revit Dlls with 2023 ) . 
However when I run the GUI it just waits forever whereas the  console application comes with an error : 

 

Unable to cast object of type 'System.Xml.XmlComment' to type 'System.Xml.XmlElement'.

 

I was wondering, since you managed to do a similar process (i.e. compile and get it to run with recent a Revit version) if you have any idea what could be the source of this error. 
Alternatively - would you be willing to write down the steps and changes that were required  for you to get the Framework to run with Revit 2021 ? 

Did you change the defaults on any library/Reference  ? Set one of the references to a specific (perhaps older) version ? 
Thanks  , Jonathan 

 

Jonathan Talisman
BIM Developer
0 Likes
Message 4 of 5

perry.swoboda
Advocate
Advocate

Hi @jonathan.taVCBM2,

Sorry for the late reply.  I had accidentally deleted my GitLab credentials and had to track them down from a backup.
All I can see I did was replace all the Revit files with versions from Revit 2023.  In all projects.

Here is a link to a GitLab with my updates.  When I get a little time I will try to make an update to the DynamoDS version.

https://gitlab.com/perry.swoboda/revittestframework

Message 5 of 5

jonathan.taVCBM2
Enthusiast
Enthusiast

Hi @perry.swoboda ,

Thanks for sharing , I could not get this to compile... 
I think it maybe that NUnit has gone through some changes and maybe I need to get an older version of NUnit via nuget , does this make any sense or does it reveal how much of a newbie I am ? 
The error I get is "the type or namespace Core does not exist in the namespace NUnit" 

Any thoughts ?

Jonathan 

Jonathan Talisman
BIM Developer
0 Likes