MATLAB Programming Fundamentals - MathWorks
Fresh Fixture Functions Use fresh fixture functions to set up and tear down states for each local test function. The names for t ...
function teardown(testCase) % do not change function name % close figure, for example end Run the Tests The figure below details ...
Related Examples “Write Simple Test Case Using Functions” on page 33-30 “Write Test Using Setup and Teardown Functions” on page ...
Write Simple Test Case Using Functions This example shows how to write a unit test for a MATLAB function, quadraticSolver.m. Cre ...
Create Test Function for Real Solutions Create a test function, testRealSolution, to verify that quadraticSolver returns the cor ...
function tests = solverTest tests = functiontests(localfunctions); end function testRealSolution(testCase) actSolution = quadrat ...
Introduce an Error in quadraticSolver.m and Run Tests Cause one of the tests to fail by forcing roots in quadraticSolver.m to be ...
Totals: 1 Passed, 1 Failed, 0 Incomplete. 0.043751 seconds testing time. The imaginary test verification failed. Restore quadrat ...
Write Test Using Setup and Teardown Functions This example shows how to write a unit test for a couple of MATLAB® figure axes pr ...
% Copyright 2015 The MathWorks, Inc. function f = createFigure f = figure; ax = axes('Parent', f); cylinder(ax,10) h = findobj(a ...
end Create Fresh Fixture Functions Fresh fixtures are function level setup and teardown code that runs before and after each tes ...
The testDefaultXLim function test verifies that the x-axis limits are large enough to display the cylinder. The lower limit need ...
Now the axesPropertiesTest.m file is complete with a main function, file fixture functions, fresh fixture functions, and two loc ...
Totals: 2 Passed, 0 Failed, 0 Incomplete. 3.5518 seconds testing time. Create Table of Test Results To access functionality avai ...
'axesPropertiesTest/testDefaultXLim' true false false 2.698 [1x1 struct] See Also matlab.unittest.constraints | matlab.unittest. ...
Extending Function-Based Tests In this section... “Fixtures for Setup and Teardown Code” on page 33-42 “Test Logging and Verbosi ...
For example, if you manually write setup and teardown code to set up a temporary folder for each test, and then you make that fo ...
Test Suite Creation Calling your function-based test returns a suite of Test objects. You also can use the testsuite function or ...
If you use one of the suite creation methods with a selector or name-value pair, the testing framework creates the filtered suit ...
Test Runner Customization Use a TestRunner object to customize the way the framework runs a test suite. With a TestRunner object ...
«
60
61
62
63
64
65
66
67
68
69
»
Free download pdf