withAnyInputs
클래스: matlab.mock.MethodCallBehavior
네임스페이스: matlab.mock
임의 개수의 임의 값을 입력값으로 받는 모의 객체 메서드 호출 지정
구문
callBehavior = withAnyInputs(behavior)
설명
callBehavior = withAnyInputs(
는 임의 값을 취할 수 있는 임의 개수의 입력값을 받아서 모의 객체 메서드가 호출된 경우의 동작을 정의하는 behavior
)MethodCallBehavior
객체를 반환합니다.
입력 인수
behavior
— 모의 객체의 동작
matlab.mock.MethodCallBehavior
인스턴스
모의 객체의 동작으로, matlab.mock.MethodCallBehavior
인스턴스로 지정됩니다. matlab.mock.MethodCallBehavior
의 인스턴스를 만들려면 해당 동작 객체의 메서드를 호출합니다.
예: myMockBehavior.myMockedMethod
예제
임의의 입력값을 받는 메서드 호출 지정하기
myMethod
메서드로 모의 객체를 만듭니다.
testCase = matlab.mock.TestCase.forInteractiveUse; [mock,behavior] = testCase.createMock('AddedMethods',"myMethod");
동작을 설정합니다. 메서드에 대한 입력값과 관계없이, "hello"
를 반환합니다.
testCase.assignOutputsWhen(withAnyInputs(behavior.myMethod),"hello")
댜앙한 입력값으로 메서드를 호출합니다.
output = mock.myMethod
output = "hello"
output = mock.myMethod(123)
output = "hello"
output = myMethod("abc",mock)
output = "hello"
임의의 입력값을 사용해 이 메서드가 한 번 이상 호출되었는지 확인합니다.
testCase.verifyCalled(withAnyInputs(behavior.myMethod))
Verification passed.
버전 내역
R2017a에 개발됨
참고 항목
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)