%% Analyze Test Case Results
% This example shows how to analyze the information returned by a test runner created from the SolverTest test case.
%
%% Create Quadratic Solver Function
% Create the following function that solves roots of the quadratic equation in a file, quadraticSolver.m, in your working folder.

type quadraticSolver.m

%
%% Create Test for Quadratic Solver Function
% Create the following test class in a file, SolverTest.m, in your working folder.

type SolverTest.m

%
%% Run SolverTest Test Case
% Create a test suite, quadTests.

quadTests = matlab.unittest.TestSuite.fromClass(?SolverTest);
result = run(quadTests);

% All tests passed.
%
%% Explore Output Argument, result
% The output argument, result, is a matlab.unittest.TestResult object. It contains information of the two tests in SolverTest.

whos result

%
%% Display Information for One Test
% To see the information for one value, type:

result(1)

%
%% Create Table of Test Results
% To access functionality available to tables, create one from the TestResult object.

rt = table(result)

% Sort the test results by duration.

sortrows(rt,'Duration')

% Export test results to a CSV file.
% writetable(rt,'myTestResults.csv','QuoteStrings',true)
% Copyright 2012 The MathWorks, Inc.