log
클래스: matlab.unittest.fixtures.Fixture
네임스페이스: matlab.unittest.fixtures
픽스처 설정 및 해제 중에 진단 정보 기록
구문
log(f,diagnostic)
log(f,v,diagnostic)
설명
log(
은 제공된 진단을 기록합니다. 로그 메서드는 픽스처(Fixture) 설정 및 해제 루틴 동안 테스트에서 정보를 기록하는 방법을 제공합니다. 테스트 프레임워크는 사용자가 적합한 플러그인(예: f
,diagnostic
)matlab.unittest.plugins.LoggingPlugin
)을 추가하여 기록된 메시지를 표시하도록 구성한 경우에만 해당 작업을 수행합니다.
log(
은 지정된 세부 정보 표시 수준 f
,v
,diagnostic
)v
로 진단을 기록합니다.
입력 인수
f
— 픽스처(Fixture)의 인스턴스
matlab.unittest.fixtures.Fixture
인스턴스
픽스처의 인스턴스로, matlab.unittest.fixtures.Fixture
로 지정됩니다.
diagnostic
— 실패 시 표시할 진단 정보
string형 | 문자형 벡터 | 함수 핸들 | matlab.automation.diagnostics.Diagnostic
인스턴스
실패 시 표시할 진단 정보로, string형, 문자형 벡터, 함수 핸들 또는 matlab.automation.diagnostics.Diagnostic
인스턴스로 지정됩니다.
v
— 세부 정보 표시 수준
2
(디폴트 값) | 1
| 3
| 4
| matlab.automation.Verbosity
열거형
세부 정보 표시 수준으로, 1에서 4 사이의 정수 값이나 matlab.automation.Verbosity
열거형 객체로 지정됩니다. 진단 메시지에 대한 디폴트 세부 정보 표시 수준은 Concise
입니다. 정수 값은 matlab.automation.Verbosity
열거형 멤버에 해당합니다.
숫자형 표현 | 열거형 멤버 이름 | 세부 정보 표시 정도 |
---|---|---|
1 | Terse | 최소한의 정보 |
2 | Concise | 중간 정도의 정보 |
3 | Detailed | 일부 자세한 정보 |
4 | Verbose | 다량의 자세한 정보 |
예제
진단 정보 기록
현재 작업 폴더의 파일 FormatHexFixture.m
에서 다음 픽스처(Fixture)를 생성합니다.
classdef FormatHexFixture < matlab.unittest.fixtures.Fixture properties (Access=private) OriginalFormat end methods function setup(fixture) fixture.OriginalFormat = format().NumericFormat; fixture.log(['The previous format setting was ',... fixture.OriginalFormat]) log(fixture,'Setting Format') format('hex') log(fixture,3,'Format Set') end function teardown(fixture) log(fixture,'Resetting Format') format(fixture.OriginalFormat) log(fixture,3,'Original Format Restored') end end end
현재 작업 폴더의 파일 SampleTest.m
에서 다음 테스트 클래스를 생성합니다.
classdef SampleTest < matlab.unittest.TestCase methods (Test) function test1(testCase) testCase.applyFixture(FormatHexFixture); actStr = getColumnForDisplay([1;2;3], 'Small Integers'); expStr = ['Small Integers ' '3ff0000000000000' '4000000000000000' '4008000000000000']; testCase.verifyEqual(actStr, expStr) end end end function str = getColumnForDisplay(values, title) elements = cell(numel(values)+1, 1); elements{1} = title; for idx = 1:numel(values) elements{idx+1} = displayNumber(values(idx)); end str = char(elements); end function str = displayNumber(n) str = strtrim(evalc('disp(n);')); end
테스트를 실행합니다.
result = run(SampleTest);
Running SampleTest . Done SampleTest __________
디폴트 테스트 실행기의 세부 정보 표시 수준이 1(Terse
)이고 디폴트 로그 메시지가 수준 2(Concise
)이기 때문에 기록된 메시지가 전혀 표시되지 않습니다.
테스트 실행기를 생성하여 수준 1, 2, 3에서 진단을 보고하고 테스트를 다시 실행합니다.
import matlab.unittest.TestRunner import matlab.unittest.plugins.LoggingPlugin ts = matlab.unittest.TestSuite.fromClass(?SampleTest); runner = TestRunner.withNoPlugins; p = LoggingPlugin.withVerbosity(3); runner.addPlugin(p); results = runner.run(ts);
[Concise] Diagnostic logged (2022-09-30T15:36:46): The previous format setting was short [Concise] Diagnostic logged (2022-09-30T15:36:46): Setting Format [Detailed] Diagnostic logged (2022-09-30T15:36:46): Format Set [Concise] Diagnostic logged (2022-09-30T15:36:47): Resetting Format [Detailed] Diagnostic logged (2022-09-30T15:36:47): Original Format Restored
버전 내역
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)