MATLAB Examples

Example 03

Generate test cases and add them to a test suite in a loop.

test_suite = junit.TestSuite();
test_suite.name='Example 03';
for r = rand(1, 5)
    test_case = junit.TestCase(matlab_ipsum('Sentences', 1, 'Paragraphs', 1, 'Words', 2, 'WordsStd', 1));
    test_case.stdout = matlab_ipsum('Sentences', 2, 'Paragraphs', 1);
    test_case.time=rand(1,1)*100+10;
    test_suite.append(test_case);
end

% Write the TestCase as an xml file with .m filename.
test_suite.xmlwrite(mfilename);
type([mfilename '.xml']);
<?xml version="1.0" encoding="utf-8"?>
<testsuites errors="0" failures="0" skipped="0" tests="5" time="255.64">
   <testsuite errors="0" failures="0" hostname="USGALWHP6047580" id="0" name="Example 03" package="matlab" skipped="0" tests="5" timestamp="2017-08-11 17:49:49">
      <testcase name="Epihed ofdts tgaai." time="68.5099" timestamp="2017-08-11 17:49:48">
         <system-out>Pcloauts vadn re iuh staaivhe tln hgeagho nuianaco?  Rwmnemon iydfr oe iiie bbaeeet tasatdtaoe adhtnvht iaoetol hoiko.</system-out>
      </testcase>
      <testcase name="Hita." time="61.5679" timestamp="2017-08-11 17:49:48">
         <system-out>Ldfoahi aenep oaoultho nnteor tieit edia.</system-out>
      </testcase>
      <testcase name="Howdaiir enooaoswo ulhiteesit!" time="23.8989" timestamp="2017-08-11 17:49:48">
         <system-out>Mtia eibt erwceanye eeeln snrejhey.  Teoldi rhoeet gcatfrep iidys eentai awmolage eioes inih tncrh.</system-out>
      </testcase>
      <testcase name="Lerka agnhnmd iiowetaw.  Lenloseivs ogaaci aoop." time="81.7902" timestamp="2017-08-11 17:49:48">
         <system-out>Gaa rlaha bleefaiii eeeme ociaofmi io drreii skett wtii frjod tak.  Mna oedtai, hftlineee ddonaa yiic.  Ereueroe nunloue, ppbeuei di.  Ulwitlh imusaqorae ariteee iaroe eerii oeieiyloi etuol.</system-out>
      </testcase>
      <testcase name="Octea idruiat ieispeuee.  Ttceaele." time="19.878" timestamp="2017-08-11 17:49:48">
         <system-out>Lan igstboriit, eicheee iihogesf eeetlsdnpa, lypot niiuii deen!  Iaaei earoa ealiaeh uhnuernv eimhee.</system-out>
      </testcase>
   </testsuite>
</testsuites>