Lesson 2: IntegratedTests, IntegratedTests and more IntegratedTests
One of the biggest goals I had in the development of the latest version of FlexiDesign was to ramp up the number of automated tests that run as part of our build system. And I am talking about Integrated Tests not unit or functional (those are important too, of course). I far prefer Integrated Tests primarily because it checks the full product from beginning to end.
Integrated Tests of a CAD add-in? Really?
But how do you test a product that is an add-in to a CAD system? The CAD system controls when the add-in product is loaded and when it is available to the end-user to interact with through a UI. It is not an easy task to simulate all these actions in an automated test (something that runs with no developer/user interaction whatsoever).
But there is a way.
So what is the solution?
If you have read my previous blog posts, then you may have found one of my downloads SWXBATCH_CEEFIT which couples the open source Integrated Test Framework (CEEFIT) with a simple wrapper to start SWX, call some SWX API, verify the output using CEEFIT, and then stop SWX. If you are interested, then read that article or even email me at ganeshram iyer [at] gmail dot com.
You can download the framework here:
http://ossandcad.googlecode.com/files/swxbatch_ceefit_6_16_2009.zip |
https://ossandcad.googlecode.com/svn/trunk/swxbatch_ceefit |
The download assumes that you have SolidWorks already installed at a specific path (I think it is C:\Program Files\SolidWorks). This is important, because SolidWorks registers its API in the Windows Registry and SWXBATCH_CEEFIT relies on that registration to call the SWX API over COM.
By default SWXBATCH_CEEFIT calls SolidWorks 2009, but making it call other versions of SolidWorks is pretty easy too:
- Simply change the headers that you #include in SWX.cpp
- If you want to build against multiple SWX versions, then create a new configuration in the project, add a preprocessor definition and use that to #ifdef which SWX headers to #include. e.g.:
#ifdef SWX2011
#include "swx2011\amapp.h"
#include "swx2011\swpublished_i.h"
#include "swx2011\swconst.h"
#else
// Solidworks includes for e.g. 2009
#include "amapp.h"
#include "swpublished_i.h"
#include "swconst.h"
#endif
- Of course you need to have the specific version of SWX installed too :)