MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
function teardown(testCase) % do not change function name
% close figure, for example
end

Run the Tests


The figure below details the tasks executed when you run the tests.

To run tests from the command prompt, use the runtests command with your MATLAB
test file as input. For example:

results = runtests('exampleTest.m')

Alternatively, you can run tests using the run function.

results = run(exampleTest)

For more information on running tests see the runtests reference page and “Run Tests
for Various Workflows” on page 33-105.

Analyze the Results


To analyze the test results, examine the output structure from runtests or run. For each
test, the result contains the name of the test function, whether it passed, failed, or didn’t
complete, and the time it took to run the test. For more information, see “Analyze Test
Case Results” on page 33-132 and “Analyze Failed Test Results” on page 33-135.

See Also
functiontests | localfunctions | runtests

33 Unit Testing

Free download pdf