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

Federico

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

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

Is there a reason why 'runtests' ignores scripts (rather than functions)? If I forget the useless line 'function testBLAH' at the beginning of a test case, then that test is silently ignored. This does not seem a sound practice, since it can lead to unnoticed failure. I strongly suggest you to fix this behaviour, unless it is intended for some reason.

02 Sep 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

This should work as a first approximation:

function assertWarningThrown(f,id)
% warning test to match assertExceptionThrown in XUnit
%
% assertWarningThrown(f,id)
%
% throws an error unless f throws a warning with id "id".
% well, in fact, unless it throws *some* warnings, whose last one has id
% "id". I don't see how to make it work in the other way.

s=warning('query',id);
warning('off',id);
lastwarn('dummy warning test','dummy:warning:id');

f();

[~,id_obtained]=lastwarn;
if strcmp(id_obtained,'dummy:warning:id')
error('assertWarningThrown:noWarning','expected warning with message_id %s, but none thrown',id);
elseif not(strcmp(id_obtained,id))
error('assertWarningThrown','expected warning %s, but got warning %s instead',id,id_obtained);
end

warning(s);

end

30 Aug 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Is there a assertWarningThrown?

Contact us