MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

plus function, the actual value might be plus(2,3) and the expected value 5. Within
the test function, you pass the actual and expected values to a qualification method. For
example:


testCase.verifyEqual(plus(2,3),5)


For an example of a basic unit test, see “Write Simple Test Case Using Classes” on page
33-51.


Additional Features for Advanced Test Classes


The MATLAB Unit Testing Framework includes several features for authoring more
advanced test classes:



  • Setup and teardown methods blocks to implicitly set up the pretest state of the system
    and return it to the original state after running the tests. For an example of a test class
    with setup and teardown code, see “Write Setup and Teardown Code Using Classes”
    on page 33-56.

  • Advanced qualification features, including actual value proxies, test diagnostics, and a
    constraint interface. For more information, see matlab.unittest.constraints
    and matlab.unittest.diagnostics.

  • Parameterized tests to combine and execute tests on the specified lists of parameters.
    For more information, see “Create Basic Parameterized Test” on page 33-82 and
    “Create Advanced Parameterized Test” on page 33-88.

  • Ready-to-use fixtures for handling the setup and teardown of frequently used testing
    actions and for sharing fixtures between classes. For more information, see
    matlab.unittest.fixtures and “Write Tests Using Shared Fixtures” on page 33-
    68.

  • Ability to create custom test fixtures. For more information see “Create Basic Custom
    Fixture” on page 33-72 and “Create Advanced Custom Fixture” on page 33-75.


See Also


Related Examples



  • “Write Simple Test Case Using Classes” on page 33-51

  • “Write Setup and Teardown Code Using Classes” on page 33-56


See Also
Free download pdf