Interactive assertion passed.
Use Mock Object Constraints
The matlab.mock.TestCase methods are convenient for spying on mock interactions.
However, there is more functionality when you use a class in the
matlab.mock.constraints package instead. To use a constraint, pass the behavior
object and constraint to the verifyThat, assumeThat, assertThat or
fatalAssertThat method.
Create a new mock object.
testCase = matlab.mock.TestCase.forInteractiveUse;
[mock,behaviorObj] = testCase.createMock('AddedProperties', ...
{'NumSides','Color'},'AddedMethods',{'roll'});
Roll 2 dice. Then use a constraint to verify that the roll method was called at least once
with two dice.
val = mock.roll(2);
import matlab.mock.constraints.WasCalled
testCase.verifyThat(behaviorObj.roll(2),WasCalled)
Interactive verification passed.
Roll one die. Then verify that the roll method was called at least twice with any inputs.
val = mock.roll(1);
testCase.verifyThat(withAnyInputs(behaviorObj.roll), ...
WasCalled('WithCount',2))
Interactive verification passed.
Verify that NumSides was not accessed.
import matlab.mock.constraints.WasAccessed
testCase.verifyThat(behaviorObj.NumSides,~WasAccessed)
Interactive verification passed.
Set the color of the dice. Then verify the property was set once.
Qualify Mock Object Interaction