TestResult Output Formats

Randy Merrill edited this page Feb 20, 2012 · 1 revision
Clone this wiki locally

MXUnit TestResult output formats

MXUnit provides a high level of flexibility by providing test results in various output formats. Some of these are preformatted, such as HTML, and others are raw to allow developers to generate customizable output formats.

The available TestResult output formats are:

  1. HTML Format
  2. ExtJs Format (deprecated)
  3. XML Format
  4. JUnit Report XML
  5. ColdFusion Query Format
  6. ColdFusion Array format
    We will use the MXUnit example found in the installation package mxunit/samples/MyTestSuite.cfm as the base TestResults. You may want to refer to your local TestResult API for details; e.g., [[http://localhost:8500/mxunit/doc/api/]

The syntax for generating the various types of output is:

<cfoutput>#output#<cfoutput>

Note: Since the above query and array types are complex data structures, you will get an error by trying to print those directly, as illustrated above. You most likely be computing other outputs if you use those types.

Following are simple examples of how to handle the various output types.

Note that in order to toggle between HTML and ExtJs format, pass in a URL.output=\[‘html’\|‘extjs’\]] to your TestSuite

1. HTML Format

The HTML output is basic preformatted HTML:


```

!assets/outputs-1.png!



*2. ExtJs Format*

ExtJs is a rich user interface set of APIs written in JavaScript.

```<cfoutput>#results.getResultsOutput( 'extjs' )#<cfoutput>

3. XML Format

This is basic raw XML format that can be transformed into custom HTML output.


```

!assets/outputs-3.png!


*4. JUnit Report XML*


This is an XML format that is used by [[Ant's JunitReport Task|http://ant.apache.org/manual/OptionalTasks/junitreport.html]]. Also see the MXUnit Ant Task for usage information.

```<cfoutput>#results.getResultsOutput( 'junitxml' )#<cfoutput>

5. ColdFusion Query Format

Returns a CF Query object that you can loop over as if it were a database query.

 <cfoutput query="q">
   #q.component#, #q.testStatus# ...
 </cfoutput>

The available columns names: COMPONENT, CONTENT, DATETIME, DEBUG, ERROR, NUMBER, TESTNAME, TESTSTATUS, TIME, TRACE.
Summary data members ( q = results.getResultsOutput(‘query’) ) :
q.testRuns = How many tests were run,
q.failures = How many tests fail,
q.errors = How many errors occurred,
q.successes = How many successes occurred,
q.totalExecutionTime = How long it took, in milliseconds, to run all the tests

">```


!assets/outputs-5.png!



*6. ColdFusion Array Format*

This is how internal test results are stored within the TestResult component.
To access specific members, you can execute the following:

``` <cfset a = results.getResultsOutput( 'array' ) />
 <cfoutput>
   #a[[1]["component"]#, #a[1]["testStatus"|]]# ...
 </cfoutput>


```

```