view m-toolbox/classes/tests/@ltpda_test_runner/get_tests_in_dir.m @ 41:6def6533cb16 database-connection-manager

Report authentication errors to user
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 18:04:34 +0100
parents f0afece42f48
children
line wrap: on
line source

% GET_TESTS_IN_DIR returns an array of test structures for the test classes
% under the given directory.
%
% The tests for the test classes found below the given directory are
% gathered in to an array of structures of the form:
%
%   test.utp     % instance of the unit test class
%   test.methods % a cell-array of the methods to be run
%
% VERSION: $Id: get_tests_in_dir.m,v 1.4 2011/05/24 19:01:25 ingo Exp $
%
function tests = get_tests_in_dir(runner, directory)
  
  tests = [];
  % generate a list of class directories under this
  classdirs = utils.prog.dirscan(directory, '@.*');
  
  for jj=1:numel(classdirs)
    [path, name, ext] = fileparts(classdirs{jj});
    clname = name(2:end);
    if strncmp(clname, 'test_', 5)
      
      try
        obj = feval(clname);
        obj.testRunner = runner;
        obj.init();
        if isa(obj, 'ltpda_utp')
          test.utp = obj;
          test.methods = obj.list_tests();
          tests = [tests test];
        end
      catch Me
        % Catch the failure if the initialisation fails.
        runner.appendErrorResult(clname, 'All methods', Me);
      end
    end
  end
  
  
end