Rank: 252215 based on 0 downloads (last 30 days) and 0 file submitted
photo

Emmet

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Emmet View all
Updated File Comments Rating
28 Feb 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

FYI, assertAlmostEqual.m (I erroneously added an 's' to the end in my earlier comment) is not in the 'xunit' directory in the zipfile. You can fetch it manually from the menu (right), but it uses 'mtest.utils.isAlmostEqual()'. If you manually change this to 'xunit.utils.isAlmostEqual()', it then works OK.

I think I've figured out why subfunction tests don't work (at least, not in R2011a). There are a number of problems. When you put in the call to the 'initTestSuite' script, it seems that the (undocumented?) '-subfun' option to 'which', which it uses to discover the subfunction names, just doesn't work, and always returns an empty array. Then, even if you can hack it to get the names of the subfunctions reliably, which I did by hacking Robert Bemis's 'SubFuns', it seems that you're in a "Catch 22": the initTestSuite script has its own variables, of course, but in the context of a function with subfunctions, adding new variables is not allowed, apparently. OTOH if you convert initTestSuite to a function, it is not then running in the context of the function with subfunctions, and the subfunctions aren't then visible, and the 'str2func' on their names (even though you now know them) fails.

Hope this helps someone save the day I just wasted.

28 Feb 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

OK, so my original comment appears to have disappeared for some reason.

In short, assertAlmostEquals() doesn't work, maybe because there's no assertAlmostEquals.m in the download.

Second, using subfunction tests, as described in "How to Put Multiple Test Cases in One M-file" doesn't appear to work at all, returning the error:

--------------------
??? Error using ==> runtests at 100
No test cases found.
--------------------

The reason for this appears to be that line 230 in TestSuite.m ( 'suite=feval(name);') gets executed and throws an exception, resulting in an empty TestSuite.

If you put this line on the Matlab command-line, it says:

--------------------
??? Attempt to add "ST" to a static workspace.
See MATLAB Programming, Restrictions on Assigning to Variables for
details.

Error in ==> initTestSuite at 18
[ST,I] = dbstack('-completenames');

Error in ==> testFluid at 2
initTestSuite;
--------------------

28 Feb 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Sorry, I mean "empty TestSuite being *returned*" not "being *caught*", above.

Contact us