MATLAB® 경로에 파일 exampleTest.m을 만듭니다. 메인 함수에서 테스트 배열을 만듭니다. 로컬 함수를 사용하여 setup 함수, teardown 함수, 두 함수 테스트를 정의합니다. 다음과 같은 파일이 생성되어야 합니다.
function tests = exampleTest
tests = functiontests(localfunctions);
function setup(testCase)
function teardown(testCase)
function exampleOneTest(testCase)
function testExampleTwo(testCase)
명령줄에서 exampleTest 함수를 호출합니다.
tests = exampleTest
tests =
1x2 Test array with properties:
Name
ProcedureName
TestClass
BaseFolder
Parameterization
SharedTestFixtures
Tags
Tests Include:
0 Parameterizations, 0 Shared Test Fixture Classes, 0 Tags.
테스트 스위트에 액세스하여 두 함수 테스트의 이름을 확인합니다.
tests.Name
ans =
'exampleTest/exampleOneTest'
ans =
'exampleTest/testExampleTwo'
로컬 테스트 함수에 대한 핸들로, 셀형 배열로 지정됩니다. 해당 파일에 대한 함수 핸들로 구성된 셀형 배열을 자동으로 생성하려면 작업 파일에 f=localfunctions를 사용하십시오. 명시적으로 테스트를 열거하려면 개별 함수를 나열하여 f를 생성(Contruct)하십시오. f에는 테스트에 필요한 setup 또는 teardown 함수를 포함해야 합니다.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.