comparison m-toolbox/classes/tests/@ltpda_test_runner/run_tests.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % RUN_TESTS runs different configurations of units tests.
2 %
3 % CALL:
4 % runner = ltpda_test_runner();
5 %
6 % The following calls are supported:
7 % runner.run_tests() % all tests under the current directory
8 % runner.run_tests('all') % all
9 % runner.run_tests('models') % only models
10 % runner.run_tests('classes') % only models
11 % runner.run_tests(<test_class>) % all tests in test class
12 % runner.run_tests(<test_class>, {... methods ...}) % only particular tests in test class
13 %
14 % VERSION: $Id: run_tests.m,v 1.3 2010/10/08 07:01:01 hewitson Exp $
15 %
16 function varargout = run_tests(varargin)
17
18 runner = varargin{1};
19 tests = [];
20
21 vlvl = LTPDAprefs.verboseLevel;
22 LTPDAprefs('Display', 'verboseLevel', 0);
23
24 current_path = path();
25
26 % Buil test list
27 switch nargin
28 case 1 % run all under this directory
29 tests = [tests runner.get_tests_in_dir('.')];
30 case 2
31 str = lower(varargin{2});
32 switch str
33 case 'all'
34 tests = [tests runner.get_builtin_model_tests()];
35 tests = [tests runner.get_class_tests()];
36 case 'models'
37 tests = [tests runner.get_builtin_model_tests()];
38 case 'classes'
39 tests = [tests runner.get_class_tests()];
40 otherwise
41 tests = [tests runner.get_tests_for_class(varargin{2})];
42 end
43
44 case 3
45
46 % all tests for this test class
47 tests = runner.get_tests_for_class(varargin{2});
48 % then set the requested methods
49 methods = varargin{3};
50 if ischar(methods)
51 methods = {methods};
52 end
53 tests.methods = methods;
54
55 otherwise
56 help(mfilename);
57 error('incorrect inputs');
58 end
59
60 % run tests
61 runner.run_test_list(tests);
62
63 path(current_path);
64 savepath;
65
66 LTPDAprefs('Display', 'verboseLevel', vlvl);
67
68 end