Revit.TestRunner - Run UnitTests in Revit

Revit.TestRunner - Run UnitTests in Revit

tobias.floescher
Contributor Contributor
1,474 Views
7 Replies
Message 1 of 8

Revit.TestRunner - Run UnitTests in Revit

tobias.floescher
Contributor
Contributor

Hello Developers,

 

In 2018 I start to program in Revit API environment. It was completely new to me, so I had to get familiar with the API and its peculiarities. I found the blog of @jeremytammik , which helped me a lot.

 

We insourced an addin, which was developed by an external company. The hole code lives in an assembly which references the Revit API. Then I realized, testing is hard. I refactured the code, that it was as much as possible independent from the Revit API. This Code was testable as I knew it, tests run on Contiguous Integration. But a lot of Code lasts on the Project referenced to Revit API.

 

I asked google what to do, but apparently there is not THE way how you solve this problem.

There is some stuff around (ex. RevitTestFramework) which seems cool, but I was not happy with it. At least all I found uses NUnit 2.6. But all my Revit independent Code is tested by the NUnit 3.x. The build server doesn’t like the mix.

 

As result, I started to write my own TestRunner using NUnit 3. It is far away from perfect, nevertheless I would like to share it with the community.

 

Please have a look at https://github.com/geberit/Revit.TestRunner

 

Features so far:

* Using NUnit 3

* No reference to Revit.TestRunner needed in test assembly

* Support of NUnit attributes SetUp and TearDown

* Injection of API objects in test method

* Works as an addin with GUI

* Installation script for libraries

* Post build event in VS project to place addin file

 

Feedback welcome

Tobias - Geberit Verwaltungs AG

0 Likes
1,475 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

Hi!

 

Nice work!

 

I've experimented with RevitTestFramework back in the days and found it interesting when I tested it. It used revit journals to start revit automatically and run the test but it often crashed for some reason. I would be great to get this to work in a CI-workflow.

 

Have you investigated the possibility to get this automated with Forge (https://forge.autodesk.com/blog/design-automation-revit-public-beta-here)?

 

 

0 Likes
Message 3 of 8

jeremytammik
Autodesk
Autodesk

Dear Tobias,

 

Thank you for your appreciation.

 

At first glance, this looks utterly beautiful!

 

I will give it a go asap!

 

Thank you ever so much for sharing this!

 

I will very gladly share it on the blog as well, if I may.

 

Thank you!

  

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 8

tobias.floescher
Contributor
Contributor

Hi Josy

 

Thanks! No I haven’t investigated with Forge at this time. But I think it could be a very cool solution, especially our build servers are build agents in azure where we don’t have any access to install something (ex. Revit).

 

tobias

0 Likes
Message 5 of 8

tobias.floescher
Contributor
Contributor

Hi Jeremy

 

Would be great if you share it on your blog!

I feel honored, thanks a lot.

 

Cheers tobias

0 Likes
Message 6 of 8

jeremytammik
Autodesk
Autodesk
0 Likes
Message 7 of 8

tobias.floescher
Contributor
Contributor

thank you very much, Jeremy.
(also to correct my terrible English ;))

0 Likes
Message 8 of 8

jeremytammik
Autodesk
Autodesk

All thanks to you!

 

You English is perfectly fine, very minor corrections only!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes