function testCallback(~,~)
callbackExecuted = true;
end
b = BankAccount(1234, 100);
b.addlistener('InsufficientFunds', @testCallback);
b.withdraw(50);
testCase.assertFalse(callbackExecuted, ...
'The callback should not have executed yet');
b.withdraw(60);
testCase.verifyTrue(callbackExecuted, ...
'The listener callback should have fired');
end
end
end
See Also
addTeardown | matlab.unittest.TestCase
Related Examples
- “Author Class-Based Unit Tests in MATLAB” on page 33-47
- “Write Simple Test Case Using Classes” on page 33-51
See Also