This code illustrates that I want to see that the generated output from this component is in fact XML, JUnit XML, and HTML. I would be looking for specific test result numbers in addition to format info. This is now all preserved in code so I won't forget.
<cfcomponent generatedOn="12-12-2007 4:35:38 AM EST" extends="mxunit.framework.TestCase">
<cffunction name="testRun">
Tests the AntRunner and makes sure the generated content is aok
<cfsavecontent variable="actual">
<cfinvoke component="#this.httpAntRunner#" method="run">
<cfinvokeargument name="type" value="dir" />
<cfinvokeargument name="value" value="#expandPath("../framework/fixture/fixturetests")#" />
<cfinvokeargument name="packagename" value="mxunit.httpantrunnertests" />
<cfinvokeargument name="outputformat" value="xml" />
</cfinvoke>
</cfsavecontent>
<!--- CF parser doesn't care for xml declaration ... --->
<cfset actual = replace(actual, '<?xml version="1.0" encoding="UTF-8"?>','','one')>
<cfset rsDom = xmlParse(actual) />
<cfset assertisXmlDoc(rsDom) />
<cfset debug(rsDom.xmlroot.xmlAttributes) />
<cfset assertEquals(rsDom.xmlroot.xmlAttributes["tests"],8,"Should only be 8 tests in this suite") />
<cfsavecontent variable="actual">
<cfinvoke component="#this.httpAntRunner#" method="run">
<cfinvokeargument name="type" value="dir" />
<cfinvokeargument name="value" value="#expandPath("../framework/fixture/fixturetests")#" />
<cfinvokeargument name="packagename" value="mxunit.httpantrunnertests" />
<cfinvokeargument name="outputformat" value="junitxml" />
</cfinvoke>
</cfsavecontent>
<cfset rsDom = xmlParse(actual) />
<cfset assertisXmlDoc(rsDom) />
<cfset debug(rsDom.xmlroot.xmlAttributes) />
<cfset assertEquals(rsDom.xmlroot.xmlAttributes["tests"],8,"Should only be 8 tests in this suite") />
<cfsavecontent variable="actual">
<cfinvoke component="#this.httpAntRunner#" method="run">
<cfinvokeargument name="type" value="dir" />
<cfinvokeargument name="value" value="#expandPath("../framework/fixture/fixturetests")#" />
<cfinvokeargument name="packagename" value="mxunit.httpantrunnertests" />
<cfinvokeargument name="outputformat" value="html" />
</cfinvoke>
</cfsavecontent>
<!--- Search for this pattern:
<title>Test Results [12/12/07 06:12:47] [127.0.0.1]</title>
--->
<cfset found = refind("<title>Test Results \[[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}[ ]*.*</title>", actual, 0, true)>
<cfset debug(found) />
<cfset assertTrue(arrayLen(found.len) gt 0) />
<cfset assertTrue(arrayLen(found.pos) gt 0) />
</cffunction>
<!--- Override these methods as needed. Note that the call to setUp() is Required if using a this-scoped instance--->
<cffunction name="setUp">
<!--- Assumption: Instantiate an instance of the component we want to test --->
<cfset this.httpAntRunner = createObject("component","mxunit.runner.HttpAntRunner") />
<!--- Add additional set up code here--->
</cffunction>
<cffunction name="tearDown"></cffunction>
</cfcomponent>

0 comments:
Post a Comment