matlab.unittest.TestSuite.run - Run test suite using default test runner - MATLAB (original) (raw)
Main Content
Class: matlab.unittest.TestSuite
Namespace: matlab.unittest
Run test suite using default test runner
Syntax
Description
results = run([suite](#mw%5Fb2b6422a-f156-448d-9a0f-c105ba4b8b6b))
runs the test suite using a default test runner, which is equivalent to the runner that the testing framework configures by default when you call the runtests function. The method returns the results of the test run as a matlab.unittest.TestResult array, where each TestResult
object corresponds to an element of suite
.
Input Arguments
Test suite, specified as a matlab.unittest.TestSuite
array.
Examples
Create a test suite from a test class, and then run the test suite.
In a file named ZerosTest.m
in your current folder, create a class-based test to test the zeros
function.
classdef ZerosTest < matlab.unittest.TestCase properties (TestParameter) type = {'single','double','uint16'}; size = struct("s2d",[3 3],"s3d",[2 5 4]); end
methods (Test)
function testClass(testCase,size,type)
testCase.verifyClass(zeros(size,type),type)
end
function testSize(testCase,size)
testCase.verifySize(zeros(size),size)
end
function testDefaultClass(testCase)
testCase.verifyClass(zeros,"double")
end
function testDefaultSize(testCase)
testCase.verifySize(zeros,[1 1])
end
function testDefaultValue(testCase)
testCase.verifyEqual(zeros,0)
end
end
end
Create a test suite from the ZerosTest
test class.
suite = testsuite("ZerosTest");
Run the test suite. All the tests pass.
Running ZerosTest .......... . Done ZerosTest
Tips
run
is a convenience method. For example,results = run(suite)
is functionally equivalent to the following code.
runner = testrunner;
results = run(runner,suite)
Version History
Introduced in R2013a