table
TimeResult
배열을 테이블로 변환
설명
입력 인수
results
— 테스트 스위트 실행 결과
matlab.unittest.TestResult
배열
테스트 스위트 실행 결과로, matlab.unittest.TestResult
배열로 지정됩니다.
예제
테스트 결과를 테이블로 생성하기
테스트 결과 집합에서 테이블을 생성하고 이 테이블을 사용하여 결과를 정렬하고 CSV 파일로 내보냅니다.
현재 폴더에서 ExampleTest
클래스를 포함하는 파일을 만듭니다.
classdef ExampleTest < matlab.unittest.TestCase methods(Test) function testOne(testCase) testCase.verifySize([1 2 3; 4 5 6],[2 3]); end function testTwo(testCase) testCase.verifyClass(@sin,?function_handle); end function testThree(testCase) testCase.assertEqual(7*2,14) end end end
명령 프롬프트에서, ExampleTest
클래스로부터 테스트 스위트를 만들고 테스트를 실행합니다.
results = run(testsuite('ExampleTest'));
Running ExampleTest ... Done ExampleTest __________
results
배열에서 테이블을 생성합니다.
rt = table(results)
rt = 3×6 table Name Passed Failed Incomplete Duration Details _________________________ ______ ______ __________ _________ ____________ {'ExampleTest/testOne' } true false false 0.0063632 {1×1 struct} {'ExampleTest/testTwo' } true false false 0.0073147 {1×1 struct} {'ExampleTest/testThree'} true false false 0.0027218 {1×1 struct}
테이블을 사용하여 테스트 결과의 요약을 표시합니다.
summary(rt)
Variables: Name: 3×1 cell array of character vectors Passed: 3×1 logical Values: True 3 False 0 Failed: 3×1 logical Values: True 0 False 3 Incomplete: 3×1 logical Values: True 0 False 3 Duration: 3×1 double Values: Min 0.0027218 Median 0.0063632 Max 0.0073147 Details: 3×1 cell
테이블 행을 내림차순으로 정렬하여 기간이 가장 긴 테스트를 찾습니다.
sorted = sortrows(rt,'Duration','descend')
sorted = 3×6 table Name Passed Failed Incomplete Duration Details _________________________ ______ ______ __________ _________ ____________ {'ExampleTest/testTwo' } true false false 0.0073147 {1×1 struct} {'ExampleTest/testOne' } true false false 0.0063632 {1×1 struct} {'ExampleTest/testThree'} true false false 0.0027218 {1×1 struct}
정렬된 결과를 CSV 파일로 내보내고 파일 내용을 봅니다.
writetable(sorted,'myTestResults.csv') type 'myTestResults.csv'
Name,Passed,Failed,Incomplete,Duration,Details ExampleTest/testTwo,1,0,0,0.0073147, ExampleTest/testOne,1,0,0,0.0063632, ExampleTest/testThree,1,0,0,0.0027218,
확장 기능
스레드 기반 환경
MATLAB®의 backgroundPool
을 사용해 백그라운드에서 코드를 실행하거나 Parallel Computing Toolbox™의 ThreadPool
을 사용해 코드 실행 속도를 높일 수 있습니다.
버전 내역
R2014b에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
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.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)