11# how to run the tests
22
3- - Install [ MOxUnit for matlab and octave] ( https://github.com/MOxUnit/MOxUnit ) to run the tests
4- - Install [ MOcov for matlab and octave] ( https://github.com/MOcov/MOcov ) to get the code coverage
5- - Make sure you are in the ` tests ` directory.
6- - Run ` moxunit_runtests ` or ` moxunit_runtests -verbose ` to run the tests.
3+ - Install [ MOxUnit for matlab and octave] ( https://github.com/MOxUnit/MOxUnit )
4+ to run the tests
5+
6+ - Install [ MOcov for matlab and octave] ( https://github.com/MOcov/MOcov ) to get
7+ the code coverage
8+
9+ - Make sure you are in the ` tests ` directory.
10+
11+ - Run ` moxunit_runtests ` or ` moxunit_runtests -verbose ` to run the tests.
712
813This should tell you which tests pass or fail.
9-
14+
1015## code coverage
1116
12- The following command would give more info and will give you HTML output in a ` coverage_html ` folder
13- showing you which lines of code is or is not checked by your test suite.
17+ The following command would give more info and will give you HTML output in a
18+ ` coverage_html ` folder showing you which lines of code is or is not checked by
19+ your test suite.
1420
15- ``` matlab
21+ ``` matlab
1622success = moxunit_runtests(pwd, ... % the path where the tests are
1723 '-verbose', ...
1824 '-with_coverage', ...
1925 '-cover', fullfile(pwd, '..'), ... % the path of the code whose coverage we want to estimate
2026 '-cover_xml_file','coverage.xml', ...
2127 '-cover_html_dir','coverage_html');
2228```
23- This will return a clear underestimation of the code coverage as the the code in dependencies in the ` lib ` folder
24- are also included in this report.
2529
26- If you want to get a slightly more accurate estimate you should run the following.
30+ This will return a clear underestimation of the code coverage as the the code in
31+ dependencies in the ` lib ` folder are also included in this report.
32+
33+ If you want to get a slightly more accurate estimate you should run the
34+ following.
2735
28- I have not been able to find a way to exclude certain files without breaking some tests.
36+ I have not been able to find a way to exclude certain files without breaking
37+ some tests.
2938
3039``` matlab
3140coverage = mocov( ...
@@ -47,15 +56,13 @@ coverage = mocov( ...
4756 '-cover_html_dir','coverage_html')
4857```
4958
50-
5159## Adding more tests
5260
5361You can use the following function template to write more tests.
5462
55-
5663``` matlab
5764function test_suite = test_functionToTest()
58- % This top function is necessary for mox unit to run tests.
65+ % This top function is necessary for mox unit to run tests.
5966 % DO NOT CHANGE IT except to adapt the name of the function.
6067 try % assignment of 'localfunctions' is necessary in Matlab >= 2016
6168 test_functions = localfunctions(); %#ok<*NASGU>
@@ -70,7 +77,7 @@ function test_functionToTestBasic()
7077
7178
7279 %% data to test against
73-
80+
7481
7582 %% test
7683 % assertTrue( );
@@ -85,7 +92,7 @@ function test_functionToTestUseCase1()
8592
8693
8794 %% data to test against
88-
95+
8996
9097 %% test
9198 % assertTrue( );
@@ -94,4 +101,3 @@ function test_functionToTestUseCase1()
94101
95102end
96103```
97-
0 commit comments