mock.Color = "blue";
import matlab.mock.constraints.WasSet
testCase.verifyThat(behaviorObj.Color,WasSet('WithCount',1))
Interactive verification passed.
Access the Color property. Then verify that it was not accessed exactly once. This test
fails.
c = mock.Color
testCase.verifyThat(behaviorObj.Color,~WasAccessed('WithCount',1))
c =
"blue"
Interactive verification failed.
---------------------
Framework Diagnostic:
---------------------
Negated WasAccessed failed.
--> Property 'Color' was accessed the prohibited number of times.
Actual property access count:
1
Prohibited property access count:
1
Specified property access:
PropertyGetBehavior
<Mock>.Color
Set the number of sides. Then, verify that the number of sides was set to 22.
mock.NumSides = 22;
testCase.verifyThat(behaviorObj.NumSides,WasSet('ToValue',22))
Interactive verification passed.
Use a constraint from the matlab.unittest.constraints package to assert that the
number of dice sides isn't set to more than 20. This test fails.
33 Unit Testing