No BSD License  

Highlights from
Unit testing tools

3.0

3.0 | 2 ratings Rate this file 8 Downloads (last 30 days) File Size: 5.56 KB File ID: #7404

Unit testing tools

by Kit Ng

 

10 Apr 2005 (Updated 12 Apr 2005)

This is a unit testing framework for MATLAB functions.

| Watch this File

File Information
Description

MatUnit is a unit testing framework for MATLAB. Much like it's Java counterpart JUnit, it allows the programmer to easily run many tests and report its results for MATLAB functions.

-We want to be able to teach students how to test numerical software.

- Many of them will have seen JUnit or similar frameworks, so a MATLAB testing framework should imitate it.

- Even if they haven't seen JUnit, it's a good framework, so MATLAB's should imitate it anyway.

- We compromised a solution of testing a list of functions, rather than creating a test class (since many users won't have seen classes)

- We created a function 'funcList' to list the names of the tests or subfunctions of an m-file. We would be grateful if someone can suggest a cleaner way.

Functions:
MatUnit --Performs each test and report the results
TestNorm--Creates list of tests that is passed to MatUnit to execute
funcList--Runs through the test file and return the subfunction/test names
norm2 --Computes the Euclidean norm

--------------------------------
Copyright (c) 2005 Kit-Sun Ng

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom theSoftware is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

Acknowledgements
This submission has inspired the following:
MATUnit
MATLAB release MATLAB 6.0 (R12)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
10 Jan 2006 Andrew Newell

In R14, each call to MatUnit gets the following warning:

-------
Warning: Non-scalar arrays of function handles will continue to work in R14, but will be illegal in R15, to support parenthesis notation for invocation of function handles. To prepare for R15, and to avoid this warning, use cell arrays of function handles instead of arrays. For more information, type 'help function_handle' and see the section at the end entitled Note on Backward Compatibility.

-----

One way this problem might be addressed is to change the function of the test file. For example, the top of testNorm could be

--------
function result = testNorm(subFunctionName)
% TESTNORM return result for a subfunction

h = str2func(subFunctionName);
result = feval(h);

% Add subfunctions here
---------------

Then testUnit could invoke funcList and run testNorm inside a loop, once for each subfunction name.

20 Jan 2006 Brad Phelan

Try out
<a href="http://xtargets.com/cms/Tutorials/Matlab-Programming/MUnit-Matlab-Unit-Testing.html">Matlab unit test</a>tools for matlab from XTargets, a free ( GPL ). It has a really nice web browser interface and control panel to organise all your unit testing from.

10 May 2006 Baosheng Ma  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
development environment Kit Ng 22 Oct 2008 07:45:26
unit test Kit Ng 22 Oct 2008 07:45:26
junit Kit Ng 22 Oct 2008 07:45:26
java Kit Ng 22 Oct 2008 07:45:26
development Kit Ng 22 Oct 2008 07:45:26
utilities Kit Ng 22 Oct 2008 07:45:26
xunit Ryan Ollos 23 Sep 2009 16:21:35
unit test Ryan Ollos 23 Sep 2009 16:21:48

Contact us at files@mathworks.com