No BSD License  

Highlights from
MUnit: a unit testing framework in Matlab

MUnit: a unit testing framework in Matlab

by

 

05 Jun 2006 (Updated )

A complete unit testing framework in Matlab

testunit(varargin)
function tu = testunit(varargin)
% @TESTUNIT/TESTSET  Generates a new test unit
%
% function tu = testunit(func,data,name,desc,callbacks)
%
%  This function is the constructor of the testset class, remember that
% this class represents a composite TestUnit.
%
%  Params
%  ------
% IN:
%  func         = The function that represents the test.
%  data         = Data that are passed to the test as params.
%  name         = The string used as name.
%  desc         = A description of the test.
%  callbacks    =  The cell of callbacks functions to be called on reset and
%                 on execution completed.
% OUT:
%  tu           = The new test unit.
%
%  Pre
%  ---
% -  Name and desc must be strings, func must be a function handle related to 
%   function that recives a test unit and a cell of params and returns two elements:
%    - The success state.
%    - The output data.
%
%  Post
%  ----
% -  The generated object is a testunit.
%
%  SeeAlso
%  -------
% testset
%
%  Examples
%  --------
%   Generating a new test unit that run the function X:
%  >> ts = testunit(@X,'MyNewTest','This is a newly created test');

% Check if the first parameter is an object of class TestUnit:
if nargin>0 && isa(varargin{1},'testunit')
    % Returning the same object
	tu = varargin{1};
    return;
end

% Generating the test set:
tu = mktestunit(varargin{:});

% Generating the class:
tu = class(tu,'testunit');

Contact us