Problem with Unit Testing Revit 2012 addin in Visual Studio 2010
I am trying to create unit test in VS2010 for Revit addin that I developed. Problem is when I create unit test for a method and then run that test, I get this message:
Test method TestProject1.SimpleTestCommandTest.ExecuteTest threw exception: System.IO.FileNotFoundException: Could not load file or assembly 'RevitAPIUI.dll' or one of its dependencies. The specified module could not be found.
RevitAPIUI.dll is properly added to references of Revit addin project, and also in references of te开发者_如何学编程st project.
Any idea what should I do to fix this?
You might want to take a look at this blog points Jeremy Tammik posted recently.
http://thebuildingcoder.typepad.com/blog/2013/07/revit-add-in-unit-testing.html
Make sure that CopyLocal is true in the properties of that reference.
NOTE: This is a rehash of my answer to the same question on the Autodesk forums that I'm posting here for SO users that may not look there. Apologies in advance if this is inappropriate.
The Revit API DLLs have dependencies on the Visual C++ Runtime. You need to ensure the VC++ Runtime is loaded into the process. Simply resolving the VC++ DLLs in an AssemblyResolve event handler produces an error that says that the runtime hasn't been loaded properly. I ran out of time and didn't go any further.
I'm also not convinced that unit testing with Revit types would work very well since most of them are tightly coupled to Revit's native code. That is, I don't think you could just new up certain elements to be used reliably in unit tests.
精彩评论