Main Content

matlab.unittest.constraints.Eventually 클래스

네임스페이스: matlab.unittest.constraints
슈퍼클래스: matlab.unittest.constraints.Constraint

함수가 제약 조건을 비동기식으로 충족하는지 테스트

설명

matlab.unittest.constraints.Eventually 클래스는 제한 시간 내에 함수 핸들이 주어진 제약 조건을 충족하는지를 폴링하는 제약 조건을 제공합니다.

matlab.unittest.constraints.Eventually 클래스는 handle 클래스입니다.

생성

설명

예제

c = matlab.unittest.constraints.Eventually(constraint)는 함수 핸들이 constraint를 충족하는지를 폴링하는 제약 조건을 만듭니다. 20초의 제한 시간 내에 함수 핸들이 constraint를 충족하는 값을 생성하면 제약 조건 c가 충족됩니다.

테스트 프레임워크는 Eventually 함수 핸들이 constraint를 충족할 때까지 기다리는 동안 Figure를 업데이트하고 보류 중인 콜백을 모두 처리합니다.

예제

c = matlab.unittest.constraints.Eventually(constraint,"WithTimeoutOf",timeout)은 지정된 제한 시간 내에 constraint가 충족되는지를 폴링하는 제약 조건을 만듭니다.

입력 인수

모두 확장

비동기식으로 충족해야 하는 제약 조건으로, matlab.unittest.constraints.Constraint 객체로 지정됩니다.

제한 시간(단위: 초)으로, 음이 아닌 숫자형 스칼라로 지정됩니다.

이 인수는 Timeout 속성을 설정합니다.

데이터형: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

속성

모두 확장

함수 핸들이 생성한 마지막 출력값으로, 임의의 데이터형 값으로 반환됩니다.

특성:

GetAccess
public
SetAccess
private

제한 시간(단위: 초)으로, 음이 아닌 숫자형 스칼라로 반환됩니다.

이 속성은 timeout 입력 인수에 의해 설정됩니다.

특성:

GetAccess
public
SetAccess
immutable

예제

모두 축소

Eventually 제약 조건을 사용하여 가설 검정(Qualification)을 최종적으로 통과하는지 테스트합니다.

먼저 이 예제에서 사용되는 클래스를 가져옵니다.

import matlab.unittest.TestCase
import matlab.unittest.constraints.Eventually
import matlab.unittest.constraints.IsGreaterThan
import matlab.unittest.constraints.IsLessThan

대화형 방식 테스트를 위한 테스트 케이스를 생성합니다.

testCase = TestCase.forInteractiveUse;

toc에 대한 호출이 tic에 대한 마지막 호출 이후 20초 내에 10보다 큰 값을 생성하는지 확인합니다. 이 테스트에서 Eventually 제약 조건은 IsGreaterThan 제약 조건이 충족되거나 경과 시간이 제한 시간을 초과할 때까지 toc을 반복적으로 호출합니다. tic을 호출한 다음 verifyThat을 호출하기 전에 10초 넘게 대기하는 경우, toc은 이미 10보다 큰 값을 생성하므로 테스트는 즉시 통과됩니다.

tic
testCase.verifyThat(@toc,Eventually(IsGreaterThan(10)))
Verification passed.

20초 내에 toc이 음수 값을 생성하는지 테스트합니다. 경과 시간이 음수일 수는 없기 때문에 테스트가 실패하더라도 Eventually는 제한 시간 동안 toc을 폴링합니다.

testCase.verifyThat(@toc,Eventually(IsLessThan(0)))
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    Eventually failed.
    --> The constraint never passed with a timeout of 20 second(s).
    --> IsLessThan failed.
        --> The value must be less than the maximum value.
        
        Actual Value:
          45.073031200000003
        Maximum Value (Exclusive):
             0
    
    Evaluated Function:
      function_handle with value:
    
        @toc

Eventually가 5초 동안 폴링하도록 제한 시간을 조정합니다. tic 호출과 verifyThat 호출 사이에 5초 넘게 대기하지 않았다면 수정된 제한 시간 내에 경과 시간이 10초를 초과하지 않으므로 테스트의 결과는 실패입니다.

tic
testCase.verifyThat(@toc,Eventually(IsGreaterThan(10), ...
    "WithTimeoutOf",5))
Verification failed.
    ---------------------
    Framework Diagnostic:
    ---------------------
    Eventually failed.
    --> The constraint never passed with a timeout of 5 second(s).
    --> IsGreaterThan failed.
        --> The value must be greater than the minimum value.
        
        Actual Value:
           5.068235800000000
        Minimum Value (Exclusive):
            10
    
    Evaluated Function:
      function_handle with value:
    
        @toc

버전 내역

R2013a에 개발됨