diff --git a/+scanreader/ScanTest.m b/+scanreader/ScanTest.m index 21931b5..ff5f785 100644 --- a/+scanreader/ScanTest.m +++ b/+scanreader/ScanTest.m @@ -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 @@ -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'); @@ -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 \ No newline at end of file +end + +% "import" functions +function c = IsEqualTo(varargin) +c = matlab.unittest.constraints.IsEqualTo(varargin{:}); +end diff --git a/+scanreader/StackTest.m b/+scanreader/StackTest.m index 19fa88d..ed237bb 100644 --- a/+scanreader/StackTest.m +++ b/+scanreader/StackTest.m @@ -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 @@ -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')}; @@ -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 + diff --git a/runALL_THE_TESTS.m b/runALL_THE_TESTS.m new file mode 100644 index 0000000..e610ae4 --- /dev/null +++ b/runALL_THE_TESTS.m @@ -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');