table
TimeResult
배열을 테이블로 변환
설명
입력 인수
테스트 스위트 실행 결과로, 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 Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)