|
News
Introduction Requirements Features White paper Distributed application testing - article |
TESTARE comes with an out of the box ant interface. An example of how to use TESTARE with ant can be found in the “samples” directory of the distribution. Invoking TESTARE from ant is as simple as this:
<project name="ant-task-test" basedir="." default="help">
<property environment="env"/>
<property name="testare.home" value="${env.TESTARE_HOME}"/>
<property name="jboss.home" value="${env.JBOSS_HOME}"/>
<target name="help">
<echo> Sample build file to run TESTARE ejb scenario tests on JBOSS. Available targets are: </echo>
<echo>run - executes the tests in the sample project
</echo>
<echo>package - builds the TESTARE enabled ear file that needs to be deployed on JBOSS</echo>
<echo>the following environment variables must be defined: TESTARE_HOME, which must point to the location where TESTARE is installed and JBOSS_HOME, which must point to the location where JBOSS is installed</echo>
</target>
<!-- target to run tests -->
<target name="run">
<!-- declare the task with the appropriate classpath. if you port this file to another app server, don't forget to include appropriate connection classes in your classpath. -->
<taskdef name="testare" classname="com.thekirschners.testare.integrations.ant.TestareAntTask">
<classpath>
<!-- include testare classes -->
<fileset dir="${testare.home}/bin">
<include name="**/*.jar"/>
</fileset>
</classpath>
<classpath>
<!-- include libraries used by testare -->
<fileset dir="${testare.home}/lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
<classpath>
<!-- include app server connection classes. mofify here if you want to port to other appservers -->
<fileset dir="${jboss.home}/client">
<include name="jbossall-client.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- execute tests in the sample project -->
<testare testCasePattern="TestCase" globalFixturePattern="Glof">
<extensionparam extension="jndi-params" name="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>
<extensionparam extension="jndi-params" name="java.naming.provider.url" value="jnp://localhost:1099"/>
<extensionparam extension="jndi-params" name="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
<!--configure a XML report printer (this is optional, you can remove it if you don't need it) ... -->
<reportprinter fqn="com.thekirschners.testare.kore.runner.reports.xml.TestResultReportXMLPrinter">
<!-- ... and specify the appropriate logger -->
<logger fqn="com.thekirschners.testare.kore.runner.reports.PrintStreamLogger">
<parameter name="filename" value="mythridreport.xml"/>
</logger>
</reportprinter>
<!--
configure a HTML report printer (this is optional, you can take it away if you don't need it) ...
-->
<reportprinter fqn="com.thekirschners.testare.kore.runner.reports.velocity.TestResultReportVelocityPrinter">
<!-- ... and specify appropriate parameters -->
<parameter name="output-folder" value="${testare.home}/samples/ejb/html"/>
<parameter name="templates-folder" value="${testare.home}/templates"/>
</reportprinter>
-
<!-- execution classpath - this must include your test cases, the tested code, as well as any other external library or module that the code you test might depend on -->
<classpath>
<pathelement location="${testare.home}/samples/ejb/bin"/>
</classpath>
<sourcepath>
<pathelement location="${testare.home}/samples/ejb/src"/>
</sourcepath>
</testare>
</target>
<!-- create the test enabled ear file -->
<target name="package">
<!-- delete old files -->
<delete file="code-to-test.jar"/>
<delete file="testare-samples.ear"/>
<!-- build jars with code that needs to be tested -->
<jar destfile="code-to-test.jar" basedir="bin">
<include name="*/**"/>
</jar>
<!-- prepare the structure and copy required files to create the ear file -->
<mkdir dir="pack-tmp"/>
<mkdir dir="ear"/>
<copy file="code-to-test.jar" todir="ear"/>
<!-- unpack the TESTARE ejb support agent -->
<unjar src="${testare.home}/bin/testare-ejb-support-ejb.jar" dest="pack-tmp"/>
<!-- repackage the TESTARE ejb support agent and include in its classpath all j2ee modules that need to be tested -->
<jar destfile="ear/testare-ejb-support-ejb.jar" basedir="pack-tmp">
<include name="*/**"/>
<manifest>
<!-- add here all j2ee modules that need to be tested -->
<attribute name="Class-Path" value="code-to-test.jar"/>
</manifest>
</jar>
<!-- build the test enabled ear file -->
<ear destfile="testare-samples.ear" appxml="earsrc/application.xml">
<fileset dir="ear" includes="*.jar"/>
</ear>
</target>
</project>
The “TESTARE” task, used to invoke the test suite runner, takes the following parameters:
The reportprinter nested element enables to declare a report printer to be used in addition to the default ant console output. The “sourcepath” nested element is a standard ant path structure that specified where the test case finder shall look for test cases and global fixtures The classpath nested element is a standard ant path structure that specified where the test runner shall load the classes that are required to properly execute the tests. IDEA and ECLIPSE integrationWork is in progress to integrate TESTARE with JUnit. This new feature will enable JUnit to discover and execute TESTARE test cases and so will can IDEA, ECLIPSE and many other IDEs. |