MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
disp('* Running setupMethod2 *')
testCase.assertEqual(1,1)
end
end

methods(Test)
function testA(testCase)
testCase.verifyTrue(true)
end
function testB(testCase)
testCase.assumeEqual(0,1)
% remaining test code is not exercised
end
function testC(testCase)
testCase.verifyFalse(true)
end
end
end

When you run the test, you see that the framework completes executes all the methods in
the TestMethodSetup block that do not contain the assumption failure, and it marks as
incomplete all methods in the Test block.

ts = matlab.unittest.TestSuite.fromClass(?ExampleTest);
res = ts.run;

Running ExampleTest

================================================================================
ExampleTest/testA was filtered.
Details
================================================================================
* Running setupMethod2 *
.
================================================================================
ExampleTest/testB was filtered.
Details
================================================================================
* Running setupMethod2 *
.
================================================================================
ExampleTest/testC was filtered.
Details
================================================================================
* Running setupMethod2 *

33 Unit Testing

Free download pdf