Skip to content

Commit f94b64e

Browse files
authored
Merge pull request #189 from ImperialCollegeLondon/test/min-release-mixin
test: Minimum release mixin
2 parents 69de8df + d160c00 commit f94b64e

4 files changed

Lines changed: 32 additions & 23 deletions

File tree

tests/system/package/tCodeAnalyzerConfiguration.m

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
classdef tCodeAnalyzerConfiguration < matlab.unittest.TestCase
1+
classdef tCodeAnalyzerConfiguration < matlab.unittest.TestCase & mag.test.mixin.RequireMinMATLABRelease
22
% TCODEANALYZERCONFIGURATION Tests for code analyzer configuration JSON
33
% file.
44

5-
properties (Constant, Access = public)
6-
ConfigurationFile = fullfile(fileparts(mfilename("fullpath")), "..", "..", "..", "resources", "codeAnalyzerConfiguration.json")
5+
properties (Constant)
6+
MinimumRelease = "R2025a"
77
end
88

9-
methods (TestClassSetup)
10-
11-
function useMATLABR2025aOrAbove(testCase)
12-
testCase.assumeFalse(isMATLABReleaseOlderThan("R2025a"), "Only MATLAB R2025a or later is supported for this test.");
13-
end
9+
properties (Constant, Access = public)
10+
ConfigurationFile = fullfile(fileparts(mfilename("fullpath")), "..", "..", "..", "resources", "codeAnalyzerConfiguration.json")
1411
end
1512

1613
methods (Test)

tests/system/package/tToolbox.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
classdef tToolbox < matlab.unittest.TestCase
1+
classdef tToolbox < matlab.unittest.TestCase & mag.test.mixin.RequireMinMATLABRelease
22
% TTOOLBOX Tests for installation of MAG Data Visualization toolbox.
33

4+
properties (Constant)
5+
MinimumRelease = "R2025a"
6+
end
7+
48
properties (Constant, Access = private)
59
PackageRoot (1, 1) string = fullfile(fileparts(mfilename("fullpath")), "..", "..", "..")
610
end
@@ -11,15 +15,11 @@
1115

1216
methods (TestClassSetup)
1317

14-
function useMATLABR2025aOrAbove(testCase)
15-
testCase.assumeFalse(isMATLABReleaseOlderThan("R2025a"), "Only MATLAB R2025a or later is supported for this test.");
16-
end
17-
1818
function checkMATLABPackage(testCase)
1919

20-
% MATLAB will still execute this method, even if the above
20+
% MATLAB will still execute this method, even if the release
2121
% check fails.
22-
if ~isMATLABReleaseOlderThan("R2025a")
22+
if ~isMATLABReleaseOlderThan(testCase.MinimumRelease)
2323
testCase.assumeEmpty(mpmlist(mag.buildtool.task.PackageTask.ToolboxName), "MAG Data Visualization installed as a MATLAB package.");
2424
end
2525
end
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
classdef (Abstract) UITestCase < matlab.uitest.TestCase
1+
classdef (Abstract) UITestCase < matlab.uitest.TestCase & mag.test.mixin.RequireMinMATLABRelease
22
% UITESTCASE Base class for all MAG UI tests.
33

4-
methods (TestClassSetup)
5-
6-
% Do not run tests in R2024a and older as not all functionality is
7-
% supported.
8-
function useMATLABR2024bOrAbove(testCase)
9-
testCase.assumeFalse(isMATLABReleaseOlderThan("R2024b"), "Only MATLAB R2024b or later is supported for this test.");
10-
end
4+
properties (Constant)
5+
MinimumRelease = "R2024b"
116
end
127
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
classdef (Abstract) RequireMinMATLABRelease < matlab.unittest.TestCase
2+
% REQUIREMINMATLABRELEASE Require a minimum MATLAB release for testing.
3+
4+
properties (Abstract, Constant)
5+
% MINIMUMRELEASE Minimum MATLAB release required.
6+
MinimumRelease (1, 1) string {mag.validator.mustMatchRegex(MinimumRelease, "^[Rr][0-9]{4}[A-Za-z]$")}
7+
end
8+
9+
methods (TestClassSetup)
10+
11+
function useMinMATLABRReleaseOrAbove(testCase)
12+
13+
testCase.assumeFalse(isMATLABReleaseOlderThan(testCase.MinimumRelease), ...
14+
compose("Only MATLAB %s or later is supported for this test.", testCase.MinimumRelease));
15+
end
16+
end
17+
end

0 commit comments

Comments
 (0)