repeat
类: matlab.mock.actions.DoNothing
命名空间: matlab.mock.actions
说明
输入参数
action
— 定义的动作
matlab.mock.actions.DoNothing
对象
定义的动作,指定为 matlab.mock.actions.DoNothing
对象。
示例: action = DoNothing
n
— 重复动作的次数
整数
重复动作的次数,指定为整数。
示例: 5
示例
重复不采取动作
为 bank account 类创建一个 mock。
testCase = matlab.mock.TestCase.forInteractiveUse; [mock,behavior] = testCase.createMock('AddedProperties',"Deposit");
指定其行为。使用 repeat
重复两次无动作,然后允许在第三次尝试中设置 Deposit
属性。
import matlab.mock.actions.DoNothing import matlab.mock.actions.StoreValue when(set(behavior.Deposit), ... DoNothing().repeat(2).then(StoreValue))
使用 mock。
for i = 1:3 mock.Deposit = 100 end
mock = Mock with properties: Deposit: []
mock = Mock with properties: Deposit: []
mock = Mock with properties: Deposit: 100
版本历史记录
在 R2020a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 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)