It would think it would take so much time and effort to build fakes to behave like they would in AutoCAD environment and then with changes to maintain you would never have time to actually use it.
....
Number of fakes required to build, mass number of system variables whose settings will change the behavior of objects, some objects require a certain order for assigning properties, so many different contexts, etc....
I am rapidly coming to the same conclusion. Andrey has already worked this out - the only way to test the behaviour of an AutoCAD object is to run the tests in AutoCAD and the way that works for him is to use Gallio.
As an aside, I tried
Microsoft Fakes but that had a lot of trouble building Fakes. When I eventually got it to build one it only worked on a few things. Chained method calls just didn't work, they didn't call the fakes after they got one layer deep.
ObjectId is a struct so faking that is problematic. Properties are relatively easy to fake but chained properties involve behaviour which is not easy to fake. Also amusing was the seven-hundred-thousand line C-sharp file that
Microsoft Fakes created.
The managed libraries are only managed wrappers and therefore only part of the AutoCAD object story anyway so faking those just won't work. Even if you manage to fake these you're faking a fake, especially if you fake the SDK DLLs which actually are fakes but dumb ones. That ain't gunna work. It didn't work.
It is necessary to separate independent and integration testing. I did it for my some application. It requires many forces and time, but it gives me big confidence about the quality of my software.
(the bold is my emphasis) Yeah, me too. I recently refactored the core of my app - this improved performance around 5x but it also broke some of my tests because I removed a lot of abstraction and disconnections to the AutoCAD objects I am manipulating. I want my tests back (now!) but I also like the way it runs now. I can see ways to test it but actually doing it is the hard part - I really need the AutoCAD objects because their behaviour and properties are an important part of the process.
The
Repo I linked to above is interesting because it has a test runner that runs inside AutoCAD. Here is the explanation I should have added in my original post (sorry)
http://civilizeddevelopment.typepad.com/civilized-development/2011/03/tinyrunner-implementing-a-civil-3d-extension.html. Here's a Google search (TypePad's search is pants) for more that Isaac has written more about the Colibra library:
https://www.google.com.au/search?q=colibra+site%3Ahttp%3A%2F%2Fcivilizeddevelopment.typepad.com This is the enxt rabbit hole I plan on diving down.
Thinking out loud here ...
Not all tests need to run in AutoCAD, just the ones that concern themselves with the properties and behaviour of AutoCAD objects. These are more integration tests than unit tests but they should still be automated and easy to create and use. My goal is to find a lightweight solution that runs tests in AutoCAD. The solution must be light-weight, flexible and future-proof. It should Just Work
TM.
Creating and managing AutoCAD objects need not be difficult, you should be able to use something like
Nunit SetUp and TearDown. Well, that's the theory.
LightweightThis has two considerations: doing and maintaining. I am not concerned that setting up the initial infrastructure would be a big job if it was easy to use and maintain.
Gallio is lightweight to run but not to maintain. Well, so is AutoCAD really but I digress. What I really want to be able to do is to set the Solution Configuration in Visual Studio and then run the tests in a test runner. It should just work. Unit tests need to be easy and fast or you just won't bother.
I also want to be able to build all the versions and run all the tests at once. With non-AutoCAD unit tests this is relatively simple, batch-build in Visual Studio the run all the tests in the NUnit test runner GUI - it works quite well. I wouldn't even care if the tests to some time to run if it was trivial to run them - a batch file that opens each CAD application, runs the tests and records the results would work for me. This could run on a Virtual Machine with a bunch of CAD applications on it. When it is finished you can reset the VM for the next lot of tests. This sounds do-able to me with a batch file and scripts to run the test runner in each application. Setting it up would be a fair bit of work but once the template was built then repeating the effort would/should be trivial.
FlexibleFor me is interesting to write the extensions for NUnit for capabilities of testing AutoCAD, nanoCAD, BricsCAD and any Teigha-based application.
Me too and I want this to work automatically. I want a process that is easy to repeat, something I can create a project template for and just add it to a Visual Studio solution, write some tests and press go.
future-proofMy main concern with Gallio is that it must be maintained and it is HUGE, so that maintenance could be a big effort.
It's kind of liberating to be stumbling around in the dark, in the broad daylight of the Internet. Care to join me? What are your thoughts?