In the past I've written test scripts outside the MATLAB xUnit Test Framework that modify the current directory or the MATLAB path so the stub functions appear first. Taking advantage of the MATLAB function name resolution rules to call something else instead.
Unfortunately, I'm still stuck developing in R2007b, haven't used the MATLAB xUnit Test Framework, and so don't have any idea if this is something the Framework or the individual test case is in a better position to handle.
David,
You say, "I believe that xUnit creates a new object for each method in that class for testing rather than iterating through the methods of a single (subclassed) TestCase object." That's correct, and that's a classic xUnit design pattern to ensure order independence of individual test methods. See http://martinfowler.com/bliki/JunitNewInstance.html.
Although it's possible to consider adding setup and teardown methods on a TestSuite level, I haven't done so for MATLAB xUnit.
Because of the release of a new unit testing framework in MATLAB itself (in R2013a), I probably will not put further effort into developing my MATLAB xUnit package. If you can upgrade to R2013a, I encourage you to give the new testing framework a try.
This maybe a my misunderstanding of the testing architecture. However, I believe that it would be useful if there were an init method in TestCase. This would be run once to setup particular parameters of dependencies. To illustrate my request further, I am using xUnit to test the submodules of a Simulink model which I am building up with model referenced components. I would like the ability to compile the model once in some init method(to take account of any new changes) and then to turn off the automatic rebuild/checking for efficiency of running the subsequent tests. Is this possible? I believe that xUnit creates a new object for each method in that class for testing rather than iterating through the methods of a single (subclassed) TestCase object.
Comment only