Main Page | Recent changes | Edit this page | Page history

Printable version | Disclaimers

127.0.0.1 (Talk)
Log in | Help
 

Ant-running tests

From AbbotWiki

overview

The preferred way to automate the running of lots of tests is via Ant.

pure ant tests

If you want to integrate Abbott with your ant builds (a daily build for instance) outside of an IDE. This code snippet is one way to invoke the abbot framework from an ant target without using any other custom code. This implementation does have drawbacks though, there is no easy way to get feedback from the test runs in any kind of useful format (see output="" in the java tag). You can then call this target with a parameter listing the abbot scripts to run.

<property environment="env"/>
<property name="abbot.jar" value="abbot-1.0.0.rc5/lib/abbot.jar"/>
<property name="junit.jar" value="abbot-1.0.0.rc5/junit/junit.jar"/>
<property name="abbot.test.scripts.dir" value="AbbotScripts/"/>

<target name="sys-test-run">
 <!-- java call to abbott tests -->
  <java fork="true" classname="junit.extensions.abbot.ScriptTestSuite" errorproperty="test_error" output="test_output.txt">
    <classpath>
	<pathelement location="${abbot.jar}"/>
	<pathelement location="${junit.jar}"/>
	    <fileset dir="${env.software_home\lib">
		<include name="**/*.jar"/>
	    </fileset>
	<pathelement path="${env.software_home}"/>
    </classpath>
    <arg line="${abbot.script.list}"/>
   </java>
   <fail if="${test_error}" message="Tests failed" />
</target>

running Eclipse tests

Scott Symmank 09/13/2005 08:19:53 PM:
> you might find the below [test.xml] helpful. it directly calls a
> runs a TestSuite in Eclipse, using the library.xml that
> org.eclipse.test plugin supplies.

> i tried to strip out the bea-specific stuff that i had in it, so, it
> might not ant-compile as is.
<?xml version="1.0" encoding="UTF-8"?>
<project name="org.eclipse.test" default="run">
    <dirname property="wlw.eclipse.test.dir"
        file="${ant.file.org.eclipse.test}"/>
    <property name="run.test.properties"
        location="default.properties"/>
    <property file="${run.test.properties}" />
    <echo message="Loading... ${run.test.properties}"/>
    <property name="default.properties"
        location="default.properties" />
    <property file="${default.properties}" />
    <echo message="Loading... ${default.properties}"/>

    <property name="test.xml" location="test.xml"/>

    <property environment="os" />
    <property name="org.eclipse.test.classname" value="" />
    <property name="org.eclipse.test.plugin-name" value="" />
    <property name="run.eclipse.home" location=""/>
    <property name="org.eclipse.test.type"
        value="ui-test" />
    <property name="org.eclipse.test.library.xml"
        location="${run.eclipse.home}/plugins/org.eclipse.test/library.xml"/>
    <property name="run.dir" location="${run.eclipse.home}" />
    <property name="org.eclipse.test.data-dir" location="${run.dir}/data"/>
    <property name="org.eclipse.test.failonerror" value="false" />
    <property name="enable.asserts" value="-ea"/>
    <property name="osgi.debug"  value="" />
    <property name="startup.jar" location="${run.eclipse.home}/startup.jar" />
    <property name="org.eclipse.test.vmArgs" value="${enable.asserts}" />

    <condition property="vmMemArgs" value="${vmMemArgs.jrockit}">
        <equals arg1="BEA" arg2="${os.JAVA_VENDOR}" />
    </condition>
    <property name="vmMemArgs" value="${vmMemArgs.sun}" />

    <property name="eclipse.vmArgs" value="${vmMemArgs}" />

    <echo
message="===================================================================================="/>
    <echo message="Running an eclipse
${org.eclipse.test.type} test with
${org.eclipse.test.library.xml}" />
    <echo message="Driver classname=${org.eclipse.test.classname}" />
    <echo message="Driver plugin=${org.eclipse.test.plugin-name}" />
    <echo message="failonerror=${org.eclipse.test.failonerror}"/>
    <echo message="workspace=${org.eclipse.test.data-dir}" />
    <echo message="vmargs=${eclipse.vmArgs}" />
    <echo message="extraVMargs=${org.eclipse.test.vmArgs}" />
    <echo
message="===================================================================================="/>

    <target name="run"
        description="Run a JUnit test in Eclipse; a target to be called from Eclipse.">
        <available property="run.dir.EXISTS"
            file="${run.dir}" />
        <fail unless="run.dir.EXISTS" >
            run.dir DID NOT EXIST.
            [${run.dir}]
        </fail>
        <available property="run.eclipse.home.EXISTS"
            file="${run.eclipse.home}" />
        <fail unless="run.eclipse.home.EXISTS" >
            run.eclipse.home DID NOT EXIST.
            [${run.eclipse.home}]
        </fail>
        <available
            property="org.eclipse.test.library.xml.EXISTS"
            file="${org.eclipse.test.library.xml}" />
        <fail
            unless="org.eclipse.test.library.xml.EXISTS" >
            org.eclipse.test.library.xml DID NOT EXIST.
            [${org.eclipse.test.library.xml}]
        </fail>
        <ant target="${org.eclipse.test.type}"
            antfile="${org.eclipse.test.library.xml}"
            dir="${run.dir}">
            <property name="data-dir" location="${org.eclipse.test.data-dir}" />
            <property name="plugin-name" value="${org.eclipse.test.plugin-name}" />
            <property name="classname" value="${org.eclipse.test.classname}" />
            <property name="org.eclipse.test.failonerror" value="${org.eclipse.test.failonerror}" />
            <property name="vmargs" value="${eclipse.vmArgs} " />
            <property name="extraVMargs" value="${org.eclipse.test.vmArgs}" />
        </ant>
    </target>
</project>

Retrieved from "http://abbot.sourceforge.net/wiki/index.php/Ant-running_tests"

This page has been accessed 1332 times. This page was last modified 14:35, 18 Dec 2007. Content is available under Attribution-ShareAlike.


[Main Page]
Main Page
Recent changes
Random page
Current events

Edit this page
Discuss this page
Page history
What links here
Related changes

Special pages
Bug reports