My favorites | Sign in
Project Home Downloads Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 185: JUnitXMLTestResult breaks on OpenBlueDragon 1.2 Stable
1 person starred this issue and may be notified of changes. Back to list
Status:  Deprecated
Owner:  ----
Closed:  Apr 2010


 
Reported by petermac...@gmail.com, Apr 26, 2010
What steps will reproduce the problem?
Run any test case where there is a failure when using the JUnit XML result.

What is the expected output? What do you see instead?
The cause of the issue is that the "stacktrace" is not available on
OpenBlueDragon due to the fact that the engine executes/compiles CFML code
differently.  The stracktrace on OpenBD is entirely different and not
useful to a CFML developer (I've seen it, complete uselessness).



What version of the product are you using? On what operating system?
Using latest stable of MXUnit.

Please provide any additional information below.
Use this patch to conditionally check for the stracktrace.  I sent patches
for this in the Summer of 2009 to Bill.  Did they not get rolled in?

 <cffunction name="buildXmlResults" access="public" output="false"
hint="Converts the TestResult into the xml representation">
   <cfargument name="results" type="array" required="true" />
  <cfscript>
   var i = "";
   this.resultsXML = this.resultsXML & '<testsuite name="#this.name#"
hostname="#cgi.remote_host#" tests="#this.testRuns#"
failures="#this.failures#" errors="#this.errors#"
timestamp="#dateFormat(now(),"mm/dd/yy")# #timeFormat(now(),"medium")#"
time="#this.totalExecutionTime/1000#">';
   this.resultsXML = this.resultsXML & '<properties>';
   this.resultsXML = this.resultsXML & genProps(server.coldfusion);
   this.resultsXML = this.resultsXML & genProps(server.os);
   this.resultsXML = this.resultsXML & genProps(cgi);
   this.resultsXML = this.resultsXML & genProps(cookie);
   this.resultsXML = this.resultsXML & genProps(request);
   if(isDefined("application")) this.resultsXML = this.resultsXML &
genProps(application);
   //JUnitReport XSL transformation doesn't like some of the CGI stuff,
like query string &amp;
   //CGI props should not be as important at sever level properties
   this.resultsXML = this.resultsXML & '</properties>';

   for(i = 1; i lte arrayLen(arguments.results); i = i + 1){
	   testResults = arguments.results[i];
	   this.resultsXML = this.resultsXML & '<testcase
classname="#testResults.component#" name="#testResults.testname#"
time="#testResults.time/1000#">';
	   if( listFindNoCase("Failed",testResults.testStatus)){
	   	this.resultsXML = this.resultsXML & '<failure
message="#xmlformat(testResults.error.message)# || details:
#xmlformat(testResults.error.detail)#">';
		if (StructKeyExists(testresults.error, "stacktrace")) {
			this.resultsXML = this.resultsXML &
'<![CDATA[#testResults.error.stacktrace#]]>';
		}
		this.resultsXML = this.resultsXML & '</failure>';
	   }
	   else if( listFindNoCase("Error",testResults.testStatus)) {
	   	this.resultsXML = this.resultsXML & '<error
message="#testResults.error.type#">';
		if (StructKeyExists(testresults.error, "stacktrace")) {
			this.resultsXML = this.resultsXML &
'<![CDATA[#testResults.error.stacktrace#]]>';
		}
		this.resultsXML = this.resultsXML & '</failure>';
	   }
	   this.resultsXML = this.resultsXML & '</testcase>';
   }
   this.resultsXML = this.resultsXML & '</testsuite>';
  </cfscript>
</cffunction>

Optionally, I would offer building a tag context converter.  It would take
the tag context and convert to a form that MXUnit could stick in the JUnit
results.  Let me know if you would like me to build one for you.
Apr 26, 2010
#3 petermac...@gmail.com
There is error in the above code the "error" type has a bad closing type of
"</failure>"  below is corrected function along with some nice line feeds and spaces
so the XML is actually human readable:

<cffunction name="buildXmlResults" access="public" output="false" hint="Converts the
TestResult into the xml representation">
   <cfargument name="results" type="array" required="true" />
  <cfscript>
   var i = "";
   this.resultsXML = this.resultsXML & '<testsuite name="#this.name#"
hostname="#cgi.remote_host#" tests="#this.testRuns#" failures="#this.failures#"
errors="#this.errors#" timestamp="#dateFormat(now(),"mm/dd/yy")#
#timeFormat(now(),"medium")#" time="#this.totalExecutionTime/1000#">' & Chr(10);
   this.resultsXML = this.resultsXML & '  <properties>' & Chr(10);
   this.resultsXML = this.resultsXML & '    ' & genProps(server.coldfusion) & Chr(10);
   this.resultsXML = this.resultsXML & '    ' & genProps(server.os) & Chr(10);
   this.resultsXML = this.resultsXML & '    ' & genProps(cgi) & Chr(10);
   this.resultsXML = this.resultsXML & '    ' & genProps(cookie) & Chr(10);
   this.resultsXML = this.resultsXML & '    ' & genProps(request) & Chr(10);
   if(isDefined("application")) this.resultsXML = this.resultsXML &
genProps(application);
   //JUnitReport XSL transformation doesn't like some of the CGI stuff, like query
string &amp;
   //CGI props should not be as important at sever level properties
   this.resultsXML = this.resultsXML & '    ' & '</properties>' & Chr(10);

   for(i = 1; i lte arrayLen(arguments.results); i = i + 1){
	   testResults = arguments.results[i];
	   this.resultsXML = this.resultsXML & '  <testcase
classname="#testResults.component#" name="#testResults.testname#"
time="#testResults.time/1000#">' & Chr(10);
	   if( listFindNoCase("Failed",testResults.testStatus)){
	   	this.resultsXML = this.resultsXML & '    <failure
message="#xmlformat(testResults.error.message)# || details:
#xmlformat(testResults.error.detail)#">' & Chr(10);
		if (StructKeyExists(testresults.error, "stacktrace")) {
			this.resultsXML = this.resultsXML & '     
<![CDATA[#testResults.error.stacktrace#]]>' & Chr(10);
		}
		this.resultsXML = this.resultsXML & '    </failure>' & Chr(10);
	   }
	   else if( listFindNoCase("Error",testResults.testStatus)) {
	   	this.resultsXML = this.resultsXML & '    <error
message="#testResults.error.type#">' & Chr(10);
		if (StructKeyExists(testresults.error, "stacktrace")) {
			this.resultsXML = this.resultsXML & '     
<![CDATA[#testResults.error.stacktrace#]]>' & Chr(10);
		}
		this.resultsXML = this.resultsXML & '    </error>' & Chr(10);
	   }
	   this.resultsXML = this.resultsXML & '  </testcase>' & Chr(10);
   }
   this.resultsXML = this.resultsXML & '</testsuite>';
  </cfscript>
</cffunction>
Apr 27, 2010
Project Member #4 virtix
thanks, Peter! This is also to note that genProps also needs to escape data as per
(http://groups.google.com/group/mxunit/browse_thread/thread/6b575fa819d664eb) ...
xmlFormat(prop) ...
Jun 30, 2010
Project Member #5 virtix
Moving some, but not all, of these to jira.mxunit.org
Status: Deprecated

Powered by Google Project Hosting