MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Test with properties:
Name: 'ExampleTest/testB'
ProcedureName: 'testB'
TestClass: "ExampleTest"
BaseFolder: 'C:\work'
Parameterization: [0×0 matlab.unittest.parameters.EmptyParameter]
SharedTestFixtures: [0×0 matlab.unittest.fixtures.EmptyFixture]
Tags: {1×0 cell}


Tests Include:
0 Parameterizations, 0 Shared Test Fixture Classes, 0 Tags.


Method Setup and Teardown Code


If an assumption failure is encountered inside a TestCase method with the
TestMethodSetup attribute, MATLAB filters the method which was to be run for that
instance. If a test uses assumptions from within the TestMethodSetup block, consider
instead using the assumptions in the TestClassSetup block, which likewise filters all
Test methods in the class but is less verbose and more efficient.


One of the methods in the following TestMethodSetup block within ExampleTest.m
contains an assumption failure.


methods(TestMethodSetup)
function setupMethod1(testCase)
testCase.assumeEqual(1,0)
% remaining test code is not exercised
end
function setupMethod2(testCase)
disp(' Running setupMethod2 ')
testCase.assertEqual(1,1)
end
end


Updated ExampleTest Class Definition


classdef ExampleTest < matlab.unittest.TestCase
methods(TestMethodSetup)
function setupMethod1(testCase)
testCase.assumeEqual(1,0)
% remaining test code is not exercised
end
function setupMethod2(testCase)


Dynamically Filtered Tests
Free download pdf