6
6
- Install [ MOcov for matlab and octave] ( https://github.com/MOcov/MOcov ) to get
7
7
the code coverage
8
8
9
- - Make sure you are in the ` tests ` directory.
9
+ - Make sure the following folders and sub-folders are in the Octave / MATLAB
10
+ path:
10
11
11
- - Run ` moxunit_runtests ` or ` moxunit_runtests -verbose ` to run the tests.
12
+ - ` src `
13
+ - ` lib `
14
+ - ` tests/utils `
15
+
16
+ - Run ` moxunit_runtests tests ` or ` moxunit_runtests tests -verbose ` to run the
17
+ tests.
12
18
13
19
This should tell you which tests pass or fail.
14
20
15
- ## code coverage
21
+ ## Adding more tests
22
+
23
+ You can use the function template to write more tests.
24
+
25
+ It is in the [ ` src/templates ` folder] ( ../src/templates )
26
+
27
+ <!-- ## code coverage
28
+
29
+ A lot of what follows does not really work locally because of needing to add the right
30
+ folders to the path to get an accurate coverage.
16
31
17
32
The following command would give more info and will give you HTML output in a
18
33
`coverage_html` folder showing you which lines of code is or is not checked by
19
34
your test suite.
20
35
21
36
```matlab
22
- success = moxunit_runtests(pwd , ... % the path where the tests are
37
+ success = moxunit_runtests('tests' , ... % the path where the tests are
23
38
'-verbose', ...
24
39
'-with_coverage', ...
25
- '-cover', fullfile(pwd, '.. '), ... % the path of the code whose coverage we want to estimate
40
+ '-cover', fullfile(pwd, 'src '), ... % the path of the code whose coverage we want to estimate
26
41
'-cover_xml_file','coverage.xml', ...
27
42
'-cover_html_dir','coverage_html');
28
43
```
@@ -38,9 +53,9 @@ some tests.
38
53
39
54
```matlab
40
55
coverage = mocov( ...
41
- '-expression', ' moxunit_runtests()' , ...
56
+ '-expression', " moxunit_runtests('test')" , ...
42
57
'-verbose', ...
43
- '-cover', fullfile(pwd, '.. '), ...
58
+ '-cover', fullfile(pwd, 'src '), ...
44
59
'-cover_exclude', '*jsonread.m', ...
45
60
'-cover_exclude', '*json*code.m', ...
46
61
'-cover_exclude', '*Contents.m', ...
@@ -54,50 +69,4 @@ coverage = mocov( ...
54
69
'-cover_exclude', '*test_*', ...
55
70
'-cover_xml_file','coverage.xml', ...
56
71
'-cover_html_dir','coverage_html')
57
- ```
58
-
59
- ## Adding more tests
60
-
61
- You can use the following function template to write more tests.
62
-
63
- ``` matlab
64
- function test_suite = test_functionToTest()
65
- % This top function is necessary for mox unit to run tests.
66
- % DO NOT CHANGE IT except to adapt the name of the function.
67
- try % assignment of 'localfunctions' is necessary in Matlab >= 2016
68
- test_functions = localfunctions(); %#ok<*NASGU>
69
- catch % no problem; early Matlab versions can use initTestSuite fine
70
- end
71
- initTestSuite;
72
- end
73
-
74
- function test_functionToTestBasic()
75
-
76
- %% set up
77
-
78
-
79
- %% data to test against
80
-
81
-
82
- %% test
83
- % assertTrue( );
84
- % assertFalse( );
85
- % assertEqual( );
86
-
87
- end
88
-
89
- function test_functionToTestUseCase1()
90
-
91
- %% set up
92
-
93
-
94
- %% data to test against
95
-
96
-
97
- %% test
98
- % assertTrue( );
99
- % assertFalse( );
100
- % assertEqual( );
101
-
102
- end
103
- ```
72
+ ``` -->
0 commit comments