Since the withAnyInputs, withExactInputs, and withNargout methods of the
MethodCallBehavior class return MethodCallBehavior objects, you can use them in
qualifications. Verify that the roll method was called at least once with any inputs.
testCase.verifyCalled(withAnyInputs(behaviorObj.roll))
Interactive verification passed.
Verify that the roll method was not called with 2 outputs and any inputs.
testCase.verifyNotCalled(withNargout(2,withAnyInputs(behaviorObj.roll)))
Interactive verification passed.
Qualify Mock Property Interaction
Similar to method calls, the mock records property set and access operations. Set the
color of the dice.
mock.Color = "red"
mock =
Mock with properties:
NumSides: []
Color: "red"
Verify that the color was set.
testCase.verifySet(behaviorObj.Color)
Interactive verification passed.
Verify the color was accessed. This test passes because there is an implicit property
access when MATLAB displays the object.
testCase.verifyAccessed(behaviorObj.Color)
Interactive verification passed.
Assert that the number of sides was not set.
testCase.assertNotSet(behaviorObj.NumSides)
33 Unit Testing