Skip to content

Commit eaf5d4a

Browse files
committed
create a very basic unit test
1 parent 1369fcd commit eaf5d4a

File tree

4 files changed

+62
-10
lines changed

4 files changed

+62
-10
lines changed

.github/workflows/moxunit.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches: '*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
submodules: true
17+
fetch-depth: 1
18+
- name: MOxUnit Action
19+
uses: joergbrech/[email protected]
20+
with:
21+
tests: tests
22+
src: src
23+
with_coverage: true
24+
cover_xml_file: coverage.xml
25+
- name: Code coverage
26+
uses: codecov/codecov-action@v1
27+
with:
28+
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
29+
file: coverage.xml # optional
30+
flags: unittests # optional
31+
name: codecov-umbrella # optional
32+
fail_ci_if_error: true # optional (default = false)

initEnv.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
% - struct
99
% - statistics
1010
%
11-
% MATLAB > R2017a
11+
% MATLAB >= R2015b
1212
%
1313
% 2 - Add project to the O/M path
1414

@@ -58,7 +58,9 @@
5858

5959
% If external dir is empty throw an exception
6060
% and ask user to update submodules.
61-
if numel(dir('lib')) <= 2 % Means that the external is empty
61+
libDirectory = fullfile(fileparts(mfilename('fullpath')), 'lib');
62+
63+
if numel(dir(libDirectory)) <= 2 % Means that the external is empty
6264
error(['Git submodules are not cloned!', ...
6365
'Try this in your terminal:', ...
6466
' git submodule update --recursive ']);

subfun/expDesign.m

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,7 @@
5757

5858
% Set variables here for a dummy test of this function
5959
if nargin < 1 || isempty(cfg)
60-
% cfg.design.motionType = 'translation';
61-
cfg.design.motionType = 'translation';
62-
cfg.design.names = {'static'; 'motion'};
63-
cfg.design.nbRepetitions = 10;
64-
cfg.design.nbEventsPerBlock = 12;
65-
cfg.dot.speedPixPerFrame = 4;
66-
cfg.target.maxNbPerBlock = 1;
67-
displayFigs = 1;
60+
error('give me something to work with')
6861
end
6962

7063
fprintf('\n\nCreating design.\n\n')

tests/test_exDesign.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function test_suite = test_exDesign %#ok<*STOUT>
2+
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
3+
test_functions = localfunctions(); %#ok<*NASGU>
4+
catch % no problem; early Matlab versions can use initTestSuite fine
5+
end
6+
initTestSuite;
7+
end
8+
9+
function test_checkCfgDefault()
10+
11+
initEnv();
12+
13+
% cfg.design.motionType = 'translation';
14+
cfg.design.motionType = 'translation';
15+
cfg.design.names = {'static'; 'motion'};
16+
cfg.design.nbRepetitions = 10;
17+
cfg.design.nbEventsPerBlock = 12;
18+
cfg.dot.speedPixPerFrame = 4;
19+
cfg.target.maxNbPerBlock = 1;
20+
displayFigs = 1;
21+
22+
[cfg] = expDesign(cfg, displayFigs)
23+
24+
25+
end

0 commit comments

Comments
 (0)