Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions +scanreader/ScanTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
classdef ScanTest < matlab.unittest.TestCase
%SCANTEST Test scans from different ScanImage versions.
properties
dataDir = '/home/ecobost/Documents/scanreader/data'
dataDir = fullfile(getenv('WORKSPACE'),'data');
scanFile5_1 % 2 channels, 3 slices
scanFile5_2 % 2 channels, 3 slices
scanFile2016bMultiroi % all rois have same dimensions, 1 channel 5 slices
Expand All @@ -14,6 +14,8 @@

methods (TestClassSetup)
function createfilenames(testCase)
testCase.assumeThat(exist(testCase.dataDir), IsEqualTo(7), ...
'The data could not be found. It cant be checked into the repo due to size constraints.');
testCase.scanFile5_1 = fullfile(testCase.dataDir, 'scan_5_1_001.tif');
testCase.scanFile5_2 = fullfile(testCase.dataDir, 'scan_5_2.tif');
testCase.scanFile2016bMultiroi = fullfile(testCase.dataDir, 'scan_2016b_multiroi_001.tif');
Expand Down Expand Up @@ -333,9 +335,14 @@ function testexceptions(testCase)

methods
% Local functions
function assertequalshapeandsum(testCase, array, expectedShape, expectedSum)
testCase.verifyEqual(size(array), expectedShape)
testCase.verifyEqual(sum(array(:)), expectedSum)
function assertequalshapeandsum(testCase, array, expectedSize, expectedSum)
testCase.assertSize(array, expectedSize);
testCase.assertEqual(sum(array(:)), expectedSum);
end
end
end
end

% "import" functions
function c = IsEqualTo(varargin)
c = matlab.unittest.constraints.IsEqualTo(varargin{:});
end
13 changes: 10 additions & 3 deletions +scanreader/StackTest.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
classdef StackTest < matlab.unittest.TestCase
%STACKTEST Test stacks from different ScanImage versions.
properties
dataDir = '/home/ecobost/Documents/scanreader/data'
dataDir = fullfile(getenv('WORKSPACE'),'data');
stackFile5_1 % 2 channels, 60 slices
stackFile2016b % 1 channel, 1 slice, mroiEnable = false
stackFile5_1Multifiles % second has 10 slices
Expand All @@ -10,6 +10,8 @@

methods (TestClassSetup)
function createfilenames(testCase)
testCase.assumeThat(exist(testCase.dataDir), IsEqualTo(7), ...
'The data could not be found. It cant be checked into the repo due to size constraints.');
testCase.stackFile5_1 = fullfile(testCase.dataDir, 'stack_5_1_001.tif');
testCase.stackFile2016b = fullfile(testCase.dataDir, 'stack_2016b.tif');
testCase.stackFile5_1Multifiles = {fullfile(testCase.dataDir, 'stack_5_1_001.tif'), fullfile(testCase.dataDir, 'stack_5_1_002.tif')};
Expand Down Expand Up @@ -193,9 +195,14 @@ function test2016bmultiroi(testCase)
methods
% Local functions
function assertequalshapeandsum(testCase, array, expectedShape, expectedSum)
testCase.verifyEqual(size(array), expectedShape)
testCase.verifyEqual(sum(array(:)), expectedSum)
testCase.assertSize(array, expectedShape)
testCase.assertEqual(sum(array(:)), expectedSum)
end
end
end

% "Import" functions
function c = IsEqualTo(varargin)
c = matlab.unittest.constraints.IsEqualTo(varargin{:});
end

31 changes: 31 additions & 0 deletions runALL_THE_TESTS.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
try
import('matlab.unittest.TestRunner');
import('matlab.unittest.plugins.XMLPlugin');
import('matlab.unittest.plugins.ToFile');
import('matlab.unittest.plugins.CodeCoveragePlugin');
import('matlab.unittest.plugins.codecoverage.CoberturaFormat');

ws = getenv('WORKSPACE');

suite = testsuite('scanreader');

% Create and configure the runner
runner = TestRunner.withTextOutput('Verbosity',3);

% Add the XML plugin
resultsDir = fullfile(ws, 'testresults');
mkdir(resultsDir);

resultsFile = fullfile(resultsDir, 'testResults.xml');
runner.addPlugin(XMLPlugin.producingJUnitFormat(resultsFile));

coverageFile = fullfile(resultsDir, 'cobertura.xml');
runner.addPlugin(CodeCoveragePlugin.forPackage('scanreader',...
'Producing', CoberturaFormat(coverageFile),'IncludingSubpackages',true));

results = runner.run(suite)
catch e
disp(getReport(e,'extended'));
exit(1);
end
quit('force');