66- Install [ MOcov for matlab and octave] ( https://github.com/MOcov/MOcov ) to get
77 the code coverage
88
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:
1011
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.
1218
1319This should tell you which tests pass or fail.
1420
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.
1631
1732The following command would give more info and will give you HTML output in a
1833`coverage_html` folder showing you which lines of code is or is not checked by
1934your test suite.
2035
2136```matlab
22- success = moxunit_runtests(pwd , ... % the path where the tests are
37+ success = moxunit_runtests('tests' , ... % the path where the tests are
2338 '-verbose', ...
2439 '-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
2641 '-cover_xml_file','coverage.xml', ...
2742 '-cover_html_dir','coverage_html');
2843```
@@ -38,9 +53,9 @@ some tests.
3853
3954```matlab
4055coverage = mocov( ...
41- '-expression', ' moxunit_runtests()' , ...
56+ '-expression', " moxunit_runtests('test')" , ...
4257 '-verbose', ...
43- '-cover', fullfile(pwd, '.. '), ...
58+ '-cover', fullfile(pwd, 'src '), ...
4459 '-cover_exclude', '*jsonread.m', ...
4560 '-cover_exclude', '*json*code.m', ...
4661 '-cover_exclude', '*Contents.m', ...
@@ -54,50 +69,4 @@ coverage = mocov( ...
5469 '-cover_exclude', '*test_*', ...
5570 '-cover_xml_file','coverage.xml', ...
5671 '-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