-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathexSilentRunning.m
76 lines (53 loc) · 2.05 KB
/
exSilentRunning.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%% <../index.html MATLAB xUnit Test Framework>: How to Run Tests Silently and Query the Results
% When you run a test suite using |runxunit|, the results are
% summarized in the Command Window. This example shows you how to
% run a test suite so that nothing prints to the Command Window, and
% it shows you how to write a program to automatically determine the
% results of running the test suite.
%
% There are four steps to follow.
%
% 1. Construct a |TestSuite| object. In this example we'll use the |fromPwd|
% method of the |TestSuite| class to construct a test suite using all the test
% cases found in the |examples_general| directory.
cd examples_general
suite = TestSuite.fromPwd();
%%
% You can look up information about the individual test cases.
suite.TestComponents{1}
%%
% You can see above that the first test component in the test suite is itself
% another test suite, which contains the test cases defined by the M-file named
% TestUsingTestCase. Here's what one of these individual test cases looks like:
suite.TestComponents{1}.TestComponents{1}
%%
% 2. Construct a TestLogger object. This object can receive
% notifications about what happens when a test suite is executed.
logger = TestRunLogger;
%%
% 3. Call the |run| method of the |TestSuite| object, passing it the
% logger.
suite.run(logger);
%%
% The |TestLogger| object can now be queried to determine what
% happened during the test.
logger
%%
% There were eight test cases run (logger.NumTestCases), resulting in
% one test failure and one test error. Detailed information about
% what went wrong can be found in |logger.Faults|.
logger.Faults(1)
%%
logger.Faults(2)
%%
% You can drill further to determine the names of the failing tests,
% as well as the complete stack trace associated with each failure.
logger.Faults(1).TestCase
%%
logger.Faults(1).Exception.stack(1)
%%
logger.Faults(1).Exception.stack(2)
%%
% <../index.html Back to MATLAB xUnit Test Framework>
%%
% Copyright 2008-2010 The MathWorks, Inc.