MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

results = runtests({'ExampleTagTest','ExampleTagClassTest'},'Tag','FeatureA');


Running ExampleTagTest
..
Done ExampleTagTest




Running ExampleTagClassTest
.
Done ExampleTagClassTest




runtests selected and ran three tests.


Display the results in a table.


table(results)


ans =


3×6 table


Name Passed Failed Incomplete Duration Details




'ExampleTagTest/testE' true false false 0.00039529 [1×1 struct]
'ExampleTagTest/testD' true false false 0.00045658 [1×1 struct]
'ExampleTagClassTest/testH' true false false 0.00043899 [1×1 struct]


The selected tests are testE and testD from ExampleTagTest, and testH from
ExampleTagClassTest.


Select Tests Using TestSuite Methods


Create a suite of tests from the ExampleTagTest class that are tagged with
'FeatureA'.


import matlab.unittest.TestSuite
sA = TestSuite.fromClass(?ExampleTagTest,'Tag','FeatureA');


Create a suite of tests from the ExampleTagClassTest class that are tagged with
'FeatureC'.


sB = TestSuite.fromFile('ExampleTagClassTest.m','Tag','FeatureC');


Concatenate the suite and view the names of the tests.


Tag Unit Tests
Free download pdf