Code covered by the BSD License  

Highlights from
XMLTestRunDisplay

4.5

4.5 | 2 ratings Rate this file 21 Downloads (last 30 days) File Size: 10.8 KB File ID: #33971

XMLTestRunDisplay

by

 

28 Nov 2011 (Updated )

JUnit-style XML logger for MATLAB xunit framework

| Watch this File

File Information
Description

This provides JUnit-style XML logging for the MATLAB xunit framework developed by Steve Eddin (http://www.mathworks.com/matlabcentral/fileexchange/22846). The code was developed with version 3.0.1 and supports xunit-style and m-file-style tests. We use this in conjunction with Hudson/Jenkins to track test results.

Below is a code sample illustrating use of the extension. See example.m for details.

%add source code to path
addpath('src');
addpath(<path to xunit>);

%import classses, functions
import edu.stanford.covert.test.runtests;
import edu.stanford.covert.test.XMLTestRunDisplay;

%run and log tests
monitor = XMLTestRunDisplay(<Name>, <description>, <output file name>);
runtests(monitor, <tests>)

Acknowledgements

Matlab X Unit Test Framework inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Other requirements Requires MATLAB >= 2008a. Also requires - subversion added to the system path to collection revision information - java in order to collect computer meta data
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
18 Apr 2012 Patrick Cloke  
07 Dec 2011 Jonathan Karr

Hi John,

Thanks for your comments. Sorry I ignored m-file-style tests. I included your code in the update I posted today.

Best.
- Jonathan

07 Dec 2011 John Grogan

Hi Jonathan, Thanks for providing an update. It is worth noting that this is designed to support xUnit-style tests that subclass the TestCase class. Other test framework options such as function/initTestSuite/subfunction test code and single function test code don't produce useful xml as the test names are lost because the test names are derived from class and method names.

However, to support the other test framework types, I found the following modifications worked (around line 160 in XMLTestRunDisplay.testComponentFinished). May not be the best way to do it, but it is ok for me.

if isa(component, 'TestCase')
this.iTestCase = this.iTestCase + 1;
if strcmp(component.MethodName, 'runTestCase')
[~, filename, ~] = fileparts(component.Location);
if isempty(filename)
classname = component.Name;
else
classname = filename;
end
this.TestCases(this.iTestCase).classname = classname;
this.TestCases(this.iTestCase).name = component.Name;
else
this.TestCases(this.iTestCase).classname = class(component);
this.TestCases(this.iTestCase).name = component.MethodName;
end
this.TestCases(this.iTestCase).location = component.Location;
this.TestCases(this.iTestCase).time = component_run_time;
end

Anyway, thanks for sharing this code!

05 Dec 2011 Jonathan Karr

Hi John,
I apologize I forgot to include that additional package. Please see the updated release.
Best.
- Jonathan

03 Dec 2011 John Grogan

This XML logging would be a great extension to xUnit, unfortunately, the initial upload is not runnable due to missing package code (edu.stanford.covert.util)

Updates
05 Dec 2011

Including missing code

07 Dec 2011

Adding support for m-file-style tests following John Grogan's comments.

Contact us