Analyze Failed Test Results
This example shows how to identify and rerun failed tests.Create an Incorrect Test MethodUsing the SolverTest test case, add a method, testBadRealSolution. This test,
based on testRealSolution, calls the quadraticSolver function with inputs 1,3,2,
but tests the results against an incorrect solution, [2,1].function testBadRealSolution(testCase)
actSolution = quadraticSolver(1,3,2);
expSolution = [2,1];
testCase.verifyEqual(actSolution,expSolution)
endRun New Test SuiteSave the updated SolverTest class definition and rerun the tests.quadTests = matlab.unittest.TestSuite.fromClass(?SolverTest);
result1 = run(quadTests);Running SolverTest
..
================================================================================
Verification failed in SolverTest/testBadRealSolution.---------------------
Framework Diagnostic:
---------------------
verifyEqual failed.
--> The values are not equal using "isequaln".
--> Failure table:
Index Actual Expected Error RelativeError
_____ ______ ________ _____ _____________1 -1 2 -3 -1.5
2 -2 1 -3 -3Actual Value:
-1 -2
Expected Value:
2 1Analyze Failed Test Results