104 returnonerror =
false;
114 pckidx = strfind(dir,
" + ");
116 curPackage = dir(pckidx(1)+1:end);
117 curPackage = [strrep(strrep(curPackage,
" + ",
" . "),
" / ",)
" . "];
125 [s,f,succeeded,abort] =
MUnit.recursiveRun(dir, curPackage, returnonerror, exclude);
131 fprintf(
" \n\n Test runs aborted.\n ");
133 fprintf(
" \n\n All Class Tests finished.\n ");
136 cprintf(
" Red ",
" Failed:%d\n ",f);
155 static function [s , f , cell<char>succeeded , abort ] = recursiveRun(folder,
char currentPackage,returnonerror,
cell<char> exclude) {
157 s = 0; f = 0; succeeded = exclude;
159 if exist(folder,
" file ") ~= 7
160 folder = fullfile(pwd,folder);
161 if exist(folder,
" file ") ~= 7
162 error(
" Folder %s does not seem to exist. ",folder);
168 for idx = 1:length(dinf)
170 subdir = dinf(idx).name;
171 if ~any(strcmp(subdir,[" . "," .. "]))
172 subdir = fullfile(folder,subdir);
174 [sa,fa,succeeded,abort] = ...
175 MUnit.recursiveRun(subdir, currentPackage, returnonerror, succeeded);
189 for idx = 1:length(w.packages)
190 subdir = fullfile(w.path,[" + " w.packages[idx]]);
192 [sa,fa,succeeded,abort] =
MUnit.recursiveRun(subdir, [currentPackage w.packages[idx] " . "], returnonerror, succeeded);
203 targets = [w.m; w.classes];
206 for idx = 1:length(targets)
207 [~,n] = fileparts(targets[idx]);
212 mc = meta.class.fromName([currentPackage n]);
214 warning(" Could not instantiate class %s: %s ",[currentPackage n],ME.message);
223 for midx=1:length(mc.Methods)
224 m = mc.Methods[midx];
232 if length(m.Name) >= pl+1 ...
233 && strcmp(m.Access," public ") ...
235 && strcmpi(m.Name(1:pl),pref) ...
236 && strcmp(m.DefiningClass.Name,mc.Name)
240 fullname = [mc.Name " . " m.Name];
241 if any(strcmp(fullname,exclude))
244 lines = " @--------------@---------------@ ";
245 fprintf(2,[lines " Running "...
246 " <a href='matlab: " mc.Name " . " m.Name " '> " m.Name(6:end) " </a> " ...
247 " in <a href='matlab:edit " mc.Name " '> " mc.Name " </a> " ...
248 " ... " lines " \n "]);
250 eval([" outargs = nargout(@ " fullname " ); "]);
252 command = [" succ = " fullname " ; "];
254 command = [fullname " ; "];
257 if outargs == 0 || succ
259 succeeded[end+1] = fullname;
263 cprintf(" Red "," Failure!\n ");
268 cprintf(
MUnit.
WarnCol,[" Test " mc.Name " -> " m.Name(6:end) " failed!\nExeption information:\n "]);
276 cprintf(
MUnit.WarnCol,[" Non-static test '%s' in %s found. "...
277 " Should this be static?\n "],...
278 m.Name((length(
MUnit.TestFunctionPrefix)+1):end),...
static const BlueCol
Blue color.
Class Unit Testing Framework for Matlab.
static function succeeded = RunClassTests(dir, returnonerror, exclude)
Runs class tests recursively within the specified path.
static const TestFunctionPrefix
The prefix for any function that will be detected in the MUnit testing process.
function count = cprintf(style, format, varargin)
CPRINTF displays styled formatted text in the Command Window.
static const WarnCol
Warning color.
Global configuration class for all KerMor run-time settings.
static function KerMor theinstance = App()
The singleton KerMor instance.
static const GreenCol
Green color (the default is hardly readable)