MATLAB Examples


Example 02

JUnit xml file generated from multiple tests. One of each status type.

test_case = junit.TestCase;

tc2 = junit.TestCase;
tc2.failure('Failure Message', 'Failure Output');

tc3 = junit.TestCase;
tc3.error('Error Message', 'Error Output');

tc4 = junit.TestCase;
tc4.skipped('Skipped Message', 'Skipped Output');

% Create test suite.
test_suite = junit.TestSuite; = matlab_ipsum('Sentences', 1, 'Paragraphs', 1, 'Words', 2, 'WordsStd', 1);
% Add each of the test cases to the test suite.
test_suite.test_cases=[test_case, tc2, tc3, tc4];


Write the TestCase as an xml file with .m filename.

type([mfilename '.xml']);
<?xml version="1.0" encoding="utf-8"?>
<testsuites errors="0" failures="0" skipped="0" tests="1" time="0.00">
   <testsuite errors="0" failures="0" hostname="USGALWHP6047580" id="0" name="TestSuite" package="matlab" skipped="0" tests="1" timestamp="2017-08-11 17:49:49">
      <testcase time="0" timestamp="2017-08-11 17:49:48"/>