Run a suite of tests and throw an exception if any of the tests
failed.
In your current folder, create a file containing the ExampleTest
class. The verifySize
qualification causes a test failure.
At the command prompt, run the tests in ExampleTest
and assert
that no failing conditions were encountered. MATLAB throws an error because one of the tests failed.
Running ExampleTest
================================================================================
Verification failed in ExampleTest/testOne.
---------------------
Framework Diagnostic:
---------------------
verifySize failed.
--> The value had an incorrect size.
Actual Size:
2 3
Expected Size:
2 4
Actual Value:
1 2 3
4 5 6
------------------
Stack Information:
------------------
In C:\Users\username\Desktop\ExampleTest.m (ExampleTest.testOne) at 4
================================================================================
...
Done ExampleTest
__________
Failure Summary:
Name Failed Incomplete Reason(s)
==================================================================
ExampleTest/testOne X Failed by verification.
Error using matlab.unittest.internal.BaseTestResult/assertSuccess (line 125)
At least one test failed in the test session.