In your working folder, create the file ExampleTest.m
containing
the following test class.
At the command prompt, create a test suite from the ExampleTest
class
and a test runner.
Run the tests.
Running ExampleTest
================================================================================
Verification failed in ExampleTest/testOne.
---------------------
Framework Diagnostic:
---------------------
verifyEqual failed.
--> The values are not equal using "isequaln".
--> Failure table:
Actual Expected Error RelativeError
______ ________________ ____________________ ____________________
3.1416 3.14159265358979 7.34641020683213e-06 2.33843499679617e-06
Actual double:
3.141600000000000
Expected double:
3.141592653589793
------------------
Stack Information:
------------------
In C:\work\ExampleTest.m (ExampleTest.testOne) at 6
================================================================================
.
================================================================================
ExampleTest/testTwo was filtered.
Details
================================================================================
.
Done ExampleTest
__________
Failure Summary:
Name Failed Incomplete Reason(s)
==================================================================
ExampleTest/testOne X Failed by verification.
------------------------------------------------------------------
ExampleTest/testTwo X Filtered by assumption.
As a result of the qualifications in the test class, the first
test fails, and the second test does not complete.
Add the StopOnFailuresPlugin
to the
runner and run the tests.
Running ExampleTest
Test execution paused due to failure. Either click here or execute DBUP to shift context to its source: line 6 of "C:\work\ExampleTest.m".
During the test execution, when the failure occurs, MATLAB enters
debug mode.
Click on the hyperlinked word 'here'
to
shift debug context to your work source. If necessary, make the command
window your current window.
In workspace belonging to ExampleTest>ExampleTest.testOne at 6
Examine the variables in the workspace.
Name Size Bytes Class Attributes
act 1x1 8 double
exp 1x1 8 double
testCase 1x1 112 ExampleTest
Now, you can investigate the cause of the test failure.
For example, see if the test passes when you specify a
relative tolerance of 100*eps
.
Verification failed in ExampleTest/testOne.
---------------------
Framework Diagnostic:
---------------------
verifyEqual failed.
--> The values are not equal using "isequaln".
--> The error was not within relative tolerance.
--> Failure table:
Actual Expected Error RelativeError RelativeTolerance
______ ________________ ____________________ ____________________ ____________________
3.1416 3.14159265358979 7.34641020683213e-06 2.33843499679617e-06 2.22044604925031e-14
Actual double:
3.141600000000000
Expected double:
3.141592653589793
------------------
Stack Information:
------------------
In C:\work\ExampleTest.m (ExampleTest.testOne) at 6
================================================================================
The test fails even with the specified tolerance.
Exit out of debug mode.
================================================================================
Verification failed in ExampleTest/testOne.
---------------------
Framework Diagnostic:
---------------------
verifyEqual failed.
--> The values are not equal using "isequaln".
--> Failure table:
Actual Expected Error RelativeError
______ ________________ ____________________ ____________________
3.1416 3.14159265358979 7.34641020683213e-06 2.33843499679617e-06
Actual double:
3.141600000000000
Expected double:
3.141592653589793
------------------
Stack Information:
------------------
In C:\work\ExampleTest.m (ExampleTest.testOne) at 6
================================================================================
.
================================================================================
ExampleTest/testTwo was filtered.
Details
================================================================================
.
Done ExampleTest
__________
Failure Summary:
Name Failed Incomplete Reason(s)
==================================================================
ExampleTest/testOne X Failed by verification.
------------------------------------------------------------------
ExampleTest/testTwo X Filtered by assumption.
To enter debug mode for tests that fail by assumption,
such as testTwo
in the ExampleTest
class,
include 'IncludingAssumptionFailures'
option for
the plugin.
If you run the test runner, you enter debug mode for both testOne
and testTwo
.