Monday, February 14, 2011

Continuous Test Integration, 2

Following up with my first post on CTI, here is how I automated launching Selenium to achieve Test Automation from within Ant for a client.

This uses the Selenese flavor of defining Se tests. The Java (or other RC) clients are good options as well (especially with the pending 2.0 release), but we chose this because the HTML output reports were very readable by the Product Owner.

Here is the launching target for Ant, remember to replace "YOURSuite.html" with... well... your suite of Se tests.
<target name="run.selenium">
<!-- Manual stop, to make time for starting a debugger
<input message="press enter"/>
-->
<mkdir dir="${selenium.report.dir}"/>
<java jar="${selenium.server.jar}" fork="true" resultproperty="selenium.result">
<jvmarg value="-Dhttp.proxyPort=8888"/>

<arg value="-userExtensions"/>
<arg value="${test.classes.dir}/selenium/user-extensions.js"/>
<arg line="${firefox.selenium.profile.dir.arg}"/>

<!--
<arg value="-log"/>
<arg value="${selenium.report.dir}/selenium.pb.log"/>
-->
<arg value="-htmlSuite"/>
<arg value="*firefox"/>
<arg value="${tomcat.url}"/>
<arg value="${test.classes.dir}/selenium/YOURSuite.html"/>
<arg value="${selenium.report.dir}/YOURSuiteResults.html"/>
</java>
</target>
I hope this helps others get more out of their Continuous Test Integration efforts. Please use this code for your own purposes without any warranty.

No comments: