Documentation Center

  • Trial Software
  • Product Updates
라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

functiontests

Create array of tests from handles to local functions

Syntax

Description

example

tests = functiontests(f) creates an array of tests, tests, from a cell array of handles to local functions, f. To apply defined setup and teardown functions, include their function handles in f.

Local test functions must include ‘test' at the beginning or end of the function name. functiontests must be called from within a test file.

Examples

expand all

Create Test Array

Create the file exampleTest.m in your MATLAB path. In the main function, create a test array. Use local functions to define setup, teardown, and two function tests. Your file should look like this.

function tests = exampleTest
tests = functiontests(localfunctions);

function setup(testCase)
function teardown(testCase)
function exampleOneTest(testCase)
function testExampleTwo(testCase)

From the command line, call the exampleTest function.

tests = exampleTest
tests = 

  1x2 Test array with properties:

    Name
    Parameterization
    SharedTestFixtures

Access the test suite to verify the names of the two function tests.

tests.Name
ans =

exampleTest/exampleOneTest


ans =

exampleTest/testExampleTwo

Input Arguments

expand all

f — Handles to local test functionscell array of function handles

Handles to local test functions, specified as a cell array. Use f=localfunctions in your working file to automatically generate a cell array of function handles for that file. If you want explicit test enumeration, construct f by listing individual functions. f must include any setup or teardown functions necessary for your test.

Example: f = localfunctions;

Example: f = {@setup,@exampleOneTest,@teardown};

See Also

| |

Was this topic helpful?