geberit / revit.testrunner Goto Github PK
View Code? Open in Web Editor NEWUnit Test Runner for Autodesk Revit
License: MIT License
Unit Test Runner for Autodesk Revit
License: MIT License
Hello,
I am trying to use Revit.TestRunner with NUnit TestCase attribute.
But although ordinary tests are working fine, I can't make the TestCase attribute working. After debugging these tests, I see that values in the TestCase attributes are not passed in the method and end up being null.
I looked into Revit.TestRunner code, it seems that the injection of the Application and UIApplication is removing any other parameters when invoking the method. I tried to correct that, but I don't really see where to start.
If you could point me in the right direction, I would be happy to work on a pull request!
Thanks for your work!
Opening a Revit File during the [OneTimeSetUp] causes the test runner to NOT wait for the end of the test.
To reproduce:
public class SampleTest
{
[OneTimeSetUp]
public void OneTimeSetup(UIApplication uiApplication)
{
}
[Test]
public void SampleTest(UIApplication uiApplication)
{
uiApplication.OpenAndActivateDocument(@"c:\temp\hang1.rvt");
}
}
Run "SampleTest" from the test runner => All Good
public class SampleTest
{
[OneTimeSetUp]
public void OneTimeSetup(UIApplication uiApplication)
{
uiApplication.OpenAndActivateDocument(@"c:\temp\hang1.rvt");
}
[Test]
public void SampleTest(UIApplication uiApplication)
{
}
}
Run "SampleTest" from the test runner => The test runner will display a dialog about the successful test completion WAY BEFORE the drawing finishes opening in Revit.
Please let me know if you have any questions.
[Test]
public void ShouldPassSomeTest()
{
Assert.Pass("All is OK");
}
Assert.Pass() - shouldn't cause the test runner to report failed test.
The fix should probably go into
TestInstance.ExecuteTestMethod(...)
to account for NUnit.Framework.SuccessException ?
/// <summary>
/// Executes the test method.
/// </summary>
public async Task ExecuteTestMethod( string methodName )
{
var method = Type.GetMethod( methodName );
try {
await InvokeMethod( Instance, mSetUp, mPossibleParams );
await InvokeMethod( Instance, method, mPossibleParams );
}
catch(NUnit.Framework.SuccessException e) {
//Ignore
}
finally {
await InvokeMethod( Instance, mTearDown, mPossibleParams );
}
}
I had this strange problem...
Sometimes when I execute Revit.TestRunner.Console.exe to make some tests.
I receive the message: Tests not executed! Service may not be running.
Everything is installed correctly, sometimes works fine others I receive this message...
I don't know what could be wrong, maybe my computer is slow or Revit does not have time to finish the addin initialization.
Any idea?
Hi
I install the add-in and when I start the Revit, the add-in is not clickable.
Please help me to solve this issue.
Originally posted by @Kumarravi007 in #18 (comment)
Hi,
I followed the README instructions for Getting started:
got the code -> compiled it -> ran the intallAddin .cmd (v2021)
this successfully created the TestRunner.dll and the TestRunner.addin (pointing to the dll)
when running Revit (2021) though the Button is greyed out:
here is the log if that helps:
Test.Runner.log
Hello
We are using IL-Repack to merge our assemblies and a few dependent assemblies together.
With the test assembly also added to the merged assembly, Revit TestRunner is unable to find the tests inside it.
I do not know how nunit finds the tests but when loading the merged dll, nothing shows up in the treeview. It can find the tests just fine in the unmerged test assembly, but the code loaded into Revit is in the merged dll, so it cannot run
Any help would be greatly appreciated
I am using the testrunner console application to process multiple DLL files with multiple revit versions (from 2020 up to 2023).
I'm processing everything file by file e.g. FileA gets processed in all revit versions afterwards FileB gets tested in all revit versions.
Sometimes the testrunner gives me the error "testrunner service not available". The testing pipeline remains in this state until the job times out. I tried to find the process which the testrunner opened (by its processId) and close it and restart my tests but the same thing happens again.
Afterwards i tried to manually start up revit and see if the testrunner loads correctly, but it seems like i am unable to start any revit version (there appears no error message, it just wont startup, no splashscreen at all).
The only solution to this i found so far is restarting my machine.
This behaviour occurs somewhat randomly, sometimes once in a week, sometimes multiple times a day.
Also this does not happen on a certain file or revit version. I had it happening with revit 2021 and 2023 as well as with multiple files.
If you need any further information, just let me know and ill try my best to help.
Thanks for developing this and make it available for everyone.
I am trying to install the Revit.Testrunner binaries on my machine.
After downloading it, I unzip the package and run the .cmd file from a console that is running in admin mode.
The Revit.TestRunner.addin is properly placed in the Revit Addins folder.
When I try to run revit I am getting the following error
I did disable ALL other revit addins.
If I attach a VS debugger then the only problem I see in the output window is:
Exception thrown: 'System.IO.FileLoadException' in mscorlib.dll
This happens for all the Revit versions 2019-2022 and both 3.4 and 3.5 versions of the runner
If I download the source and compile it then everything works fine.
Any idea what may be wrong/missing in the binary .zip install packages?
Hello,
I was trying to execute some tests using the Console Application without having the JSON sample of the dll.
In this case, I want to test all the methods on the dll. I suppose the only way to generate de JSON is with the Revit open using the Revit.TestRunner Addin.
I was able to mess with the opensource code and open the Revit then generate the JSON with all the Tests and then run the RunTests
.
I found this approach a little messy, there is an easy way to do that?
Thanks
Hello,
I have successfully installed the addin (building the source code) for Revit 2024. However, it is disabled in the ribbon - it is "greyed" out and when clicking on the icon nothing happens. Do you know what might be the issue?
The adding looks super useful, so I hope the problem can be resolved.
Thank you.
LOGS:
2023-07-25 15:40:00,834 [1] INFO Revit.TestRunner.Log - Revit.TestRunner started v1.4.0.0 '25/07/2023 3:40:00 pm'
2023-07-25 15:40:00,841 [1] INFO Revit.TestRunner.Log - Microsoft Windows NT 10.0.19045.0, NetFX 4.0.30319.42000
2023-07-25 15:40:00,843 [1] DEBUG Revit.TestRunner.Log - Log Directory 'C:\Repos\GithubOthers\Revit.TestRunner\src\bin\Addin'
2023-07-25 15:40:00,843 [1] DEBUG Revit.TestRunner.Log - CurrentAppDomain.ApplicationBase 'C:\Program Files\Autodesk\Revit 2024'
2023-07-25 15:40:00,867 [1] INFO Revit.TestRunner.Log - Service started '25/07/2023 3:40:00 pm'
2023-07-25 15:41:31,297 [1] INFO Revit.TestRunner.Log - Service stopped '25/07/2023 3:41:31 pm'
2023-07-25 15:42:45,096 [1] INFO Revit.TestRunner.Log - Revit.TestRunner started v1.4.0.0 '25/07/2023 3:42:45 pm'
2023-07-25 15:42:45,103 [1] INFO Revit.TestRunner.Log - Microsoft Windows NT 10.0.19045.0, NetFX 4.0.30319.42000
2023-07-25 15:42:45,105 [1] DEBUG Revit.TestRunner.Log - Log Directory 'C:\Repos\GithubOthers\Revit.TestRunner\src\bin\Addin'
2023-07-25 15:42:45,105 [1] DEBUG Revit.TestRunner.Log - CurrentAppDomain.ApplicationBase 'C:\Program Files\Autodesk\Revit 2024'
2023-07-25 15:42:45,120 [1] INFO Revit.TestRunner.Log - Service started '25/07/2023 3:42:45 pm'
2023-07-25 15:42:57,923 [1] INFO Revit.TestRunner.Log - Service stopped '25/07/2023 3:42:57 pm'
2023-07-25 15:43:15,869 [1] INFO Revit.TestRunner.Log - Revit.TestRunner started v1.4.0.0 '25/07/2023 3:43:15 pm'
2023-07-25 15:43:15,876 [1] INFO Revit.TestRunner.Log - Microsoft Windows NT 10.0.19045.0, NetFX 4.0.30319.42000
2023-07-25 15:43:15,878 [1] DEBUG Revit.TestRunner.Log - Log Directory 'C:\Repos\GithubOthers\Revit.TestRunner\src\bin\Addin'
2023-07-25 15:43:15,878 [1] DEBUG Revit.TestRunner.Log - CurrentAppDomain.ApplicationBase 'C:\Program Files\Autodesk\Revit 2024'
2023-07-25 15:43:15,897 [1] INFO Revit.TestRunner.Log - Service started '25/07/2023 3:43:15 pm'
2023-07-25 15:44:08,318 [1] INFO Revit.TestRunner.Log - Service stopped '25/07/2023 3:44:08 pm'
2023-07-25 15:53:06,644 [1] INFO Revit.TestRunner.Log - Revit.TestRunner started v1.4.0.0 '25/07/2023 3:53:06 pm'
2023-07-25 15:53:06,652 [1] INFO Revit.TestRunner.Log - Microsoft Windows NT 10.0.19045.0, NetFX 4.0.30319.42000
2023-07-25 15:53:06,654 [1] DEBUG Revit.TestRunner.Log - Log Directory 'C:\Repos\GithubOthers\Revit.TestRunner\src\bin\Addin'
2023-07-25 15:53:06,654 [1] DEBUG Revit.TestRunner.Log - CurrentAppDomain.ApplicationBase 'C:\Program Files\Autodesk\Revit 2024'
2023-07-25 15:53:06,683 [1] INFO Revit.TestRunner.Log - Service started '25/07/2023 3:53:06 pm'
I am trying to use the Revit.TestRunner for some Revit testing and I am running into a problem that I hope you can help me with.
These are the steps I've done to reproduce my issue.
As a result I get an error message in the TestRunner.App status bar saying
Could not load 'C:\Work\Projects\Revit.TestRunner\src\bin\Revit.TestRunner.SampleTestProject2.dll'
Now if I attach the VS debugger to Revit, after Revit was started at step 3 and try to load the SampleTestProject2.dll then everything works fine - and I am able to run the tests.
Is there anything I am missing?
Why is that the runner cannot load the test assembly when is in debug mode?
I did try to debug the issue but obviously I did fail because everything works when the debugger is attached.
I'd appreciate your help with this problem.
Please let me know if you need any extra info/log files/etc.
Peter.
I want implement unit tests for my Revit plugins. I wrote some basic tests according to the SampleTestProject2 in the repo. Further I tried to implement a OneTimeSetUp, to load a revit project and then execute some tests using this revit project. Unfortunately the OneTimeSetup is never executed.
To reproduce, I added
[OneTimeSetUp]
public void init()
{
MessageBox.Show("OnetimeSetup wokrs!");
}
to the RevitTest-Class. But nothing happens.
If i change the lines to
[SetUp]
public void init()
{
MessageBox.Show("Setup wokrs!");
}
the message box displays two times as expected. But i want the Setup only apply once.
Further I made a Testproject using only Nunit without Revit. There, the OneTimeSetUp works.
Can you help me according this topic?
Michael
Hi Tobias,
I would like to develop test cases, build and run them using revit. Therefore I open Revit and start the TestRunner without having a Revit Project open.
If I run the tests and rebuild the test project, there is the Error:
Severity Code Description Project File Line Suppression State
Error Could not copy "obj\DEVELOPMENT\Test.dll" to "bin\DEVELOPMENT\Test.dll". Exceeded retry count of 10. Failed. The file is locked by: "Autodesk Revit (12124)" Test
By closing Revit, the Test.dll is not locked any more and the rebuild is possible. But it is time consuming to close and reopen Revit for each build process. Do you have a worklfow to avoid this behaviour?
Thanks
Michael
I noticed that the console runner prints for some longer running tests ... Test Running ...
.
These tests are not accounted in the final summary (they are not added to the total amount of run tests).
Also there will be no feedback in the console print if these tests failed or passed.
I already fixed the bug here: #21
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.