Skip to content

Commit

Permalink
move test out of package
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Feb 29, 2024
1 parent a0f8bf6 commit 6f53741
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ jobs:
uses: matlab-actions/run-tests@v2
with:
strict: true
select-by-folder: test
37 changes: 22 additions & 15 deletions buildfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,34 @@ function testTask(~)
end

function coverageTask(~)
import matlab.unittest.TestRunner;
import matlab.unittest.Verbosity;
import matlab.unittest.plugins.CodeCoveragePlugin;
import matlab.unittest.plugins.XMLPlugin;
import matlab.unittest.plugins.codecoverage.CoberturaFormat;
import matlab.unittest.TestRunner
import matlab.unittest.Verbosity
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.XMLPlugin
import matlab.unittest.plugins.codecoverage.CoberturaFormat

name = "matmap3d";

suite = testsuite(name);
pkg = "matmap3d";

suite = testsuite("test/");

% not import to allow use of rest of buildfile with R2022b
format = matlab.unittest.plugins.codecoverage.CoverageResult;

mkdir('code-coverage');
mkdir('test-results');

runner = TestRunner.withTextOutput();
runner.addPlugin(XMLPlugin.producingJUnitFormat('test-results/results.xml'));
runner.addPlugin(CodeCoveragePlugin.forFolder(pwd, IncludingSubfolders=true, Producing=CoberturaFormat('code-coverage/coverage.xml')));
runner.addPlugin(CodeCoveragePlugin.forPackage(pkg, Producing=format))

% runner.addPlugin(XMLPlugin.producingJUnitFormat('test-results.xml'))
% runner.addPlugin(CodeCoveragePlugin.forPackage(pkg, 'Producing', ...
% CoberturaFormat('test-coverage.xml')))

run_results = runner.run(suite);
assert(~isempty(run_results), "no tests found")

results = runner.run(suite);
assert(~isempty(results), "no tests found")
assertSuccess(run_results)

assertSuccess(results)
generateHTMLReport(format.Result)
end

function publishTask(~)
Expand All @@ -50,7 +57,7 @@ function publishTask(~)
files = r.Files;

% remove nuisance functions
i = contains(files, [mfilename, "buildfile.m", filesep + "private" + filesep, "Test"]);
i = contains(files, [mfilename, "buildfile.m", filesep + "private" + filesep]);
files(i) = [];

pkg = what(pkg_name);
Expand Down
10 changes: 9 additions & 1 deletion +matmap3d/unitTest.m → test/TestUnit.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
classdef unitTest < matlab.unittest.TestCase
classdef TestUnit < matlab.unittest.TestCase

properties
TestData
end



methods(TestClassSetup)
function setup_path(tc)
import matlab.unittest.fixtures.PathFixture
cwd = fileparts(mfilename("fullpath"));
top = fullfile(cwd, "..");
tc.applyFixture(PathFixture(top))
end

function setup(tc)
tc.TestData.atol = 1e-9;
Expand Down

0 comments on commit 6f53741

Please sign in to comment.