0

My question is relevant to this question, but I've somehow moved a step further and implemented a test framework using nunit.

When I run the test framework addin inside Revit, the testing framework somehow locks the test assemblies making it impossible to recompile the test assemblies. To get around it, I tried making a shadow copy so the nunit test runner runs on the copied assemblies. But once I run the tests for the first time, the subsequent test runs does not work on updated copies. It is like the test runner caches the dlls and always tries to run tests on cached copy.

So each time the test assembly is updated, I need to close-reopen Revit to run the tests which is a real pain. The main reason I implemented the testing framework for Revit was to be able to do BDD/TDD using Revit API.

This is a code snippet of how I run the tests:

    TestPackage theTestPackage = new TestPackage(testDll);
    RemoteTestRunner testRunner = new RemoteTestRunner();
    testRunner.Load(theTestPackage);
    TestResult testResult = testRunner.Run(new NullListener());

Does anyone have any idea how to solve this?

4

1 に答える 1

1

You can try loading the assemby for testing with the Assembly.Load(byte[]) method. I'm not sure if your test runner can handle this, but this will give you an assembly to work on that is loaded from a byte stream in memory. Therefore the original assembly file can be recompiled anytime and you can have as many concurrent versions of this assembly loaded as you like. They are all separate, with separate types.

I use a similar strategy with the RevitPythonShell script loadplugin.py for loading plugins at runtime and then exercising them for testing. This seems to work quite well except for WPF controls defined in XAML. I suspect the XAML parser and loader keeps a cache of the types, but haven't been able to look into this yet due to time constraints.

于 2013-01-10T09:15:27.097 に答える