I've faced with next problem.
Trying to create pilot test-project using Groovy, TestNG, ant.
If I run tests from my IDE (Eclipse) - all is ok.
But when I try run tests using ant - not easy for me problem. Could you help me?
build.xml is present below.
Compile target - pass ok, but on runTest target I see problem:
"Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObject"
<project basedir="." default="runTest" name="Ant file for TestNG">
<property name="src" location="src" />
<property name="build" location="build" />
<property name="libs" location="lib" />
<path id="class.path">
<pathelement location="${libs}/testng.jar" />
<pathelement location="lib/testng.jar"/>
<pathelement location="${build}" />
</path>
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="lib/groovy-all.jar"/>
<pathelement location="lib/testng.jar"/>
</classpath>
</taskdef>
<target name="runTest" depends="compile">
<mkdir dir="testng_output"/><!-- Create the output directory. -->
<testng outputdir="testng_output" classpathref="class.path">
<xmlfileset dir="." includes="testng.xml"/>
</testng>
</target>
<target name="compile">
<delete dir="build"/>
<mkdir dir="build"/>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="lib/groovy-all.jar"/>
<groovyc srcdir="src" destdir="./build">
<classpath>
<pathelement path="lib/groovy-all.jar"/>
<pathelement path="lib/testng.jar"/>
</classpath>
<javac source="1.7" target="1.7" debug="off" />
</groovyc>
</target>
</project>
And this is testng.xml
<suite name="My Test Suite" parallel="methods" thread-count="5">
<test name="My Test">
<classes>
<class name="test1" />
</classes>
</test>
</suite>
Related
I am trying to use ant to run junit tests and generate reports. Its give the error "BUILD FAILED" and didn't generate the report. the junit report folder is empty.
What am I doing wrong ?
This is my build.xml :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. --><project basedir="." default="build" name="SeleniumProject">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../../eclipse-jee-indigo-SR2-win32-x86_64/eclipse"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.7"/>
<property name="source" value="1.7"/>
<path id="JUnit 4.libraryclasspath">
<pathelement location="${ECLIPSE_HOME}/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
</path>
<path id="SeleniumProject.classpath">
<pathelement location="bin"/>
<path refid="JUnit 4.libraryclasspath"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/selenium-java-2.41.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/selenium-java-2.41.0-srcs.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/selenium-server-standalone-2.41.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/apache-mime4j-0.6.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/bsh-1.3.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/cglib-nodep-2.1_3.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-codec-1.8.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-collections-3.2.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-exec-1.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-io-2.2.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-jxpath-1.3.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-lang3-3.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/commons-logging-1.1.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/cssparser-0.9.11.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/guava-15.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/hamcrest-core-1.3.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/hamcrest-library-1.3.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/htmlunit-2.13.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/htmlunit-core-js-2.13.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/httpclient-4.3.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/httpcore-4.3.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/httpmime-4.3.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/ini4j-0.5.2.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jcommander-1.29.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jetty-websocket-8.1.8.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jna-3.4.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/jna-platform-3.4.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/json-20080701.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/junit-dep-4.11.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/nekohtml-1.9.19.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/netty-3.5.7.Final.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/operadriver-1.5.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/phantomjsdriver-1.1.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/protobuf-java-2.4.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/sac-1.3.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/serializer-2.7.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/testng-6.8.5.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/xalan-2.7.1.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/xercesImpl-2.10.0.jar"/>
<pathelement location="../../../../selenium-java-2.41.0/selenium-2.41.0/libs/xml-apis-1.4.01.jar"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="SeleniumProject.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="absolutexpath (1)">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="absolutexpath" todir="${junit.output.dir}"/>
<classpath refid="SeleniumProject.classpath"/>
</junit>
</target>
<target name="dropdown">
<java classname="DropDown" failonerror="true" fork="yes">
<classpath refid="SeleniumProject.classpath"/>
</java>
</target>
<target name="relativexpath (1)">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="relativexpath" todir="${junit.output.dir}"/>
<classpath refid="SeleniumProject.classpath"/>
</junit>
</target>
<target name="verifytextbycss">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="Verifytextbycss" todir="${junit.output.dir}"/>
<classpath refid="SeleniumProject.classpath"/>
</junit>
</target>
<target name="Verifytextbyid (1)">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="Verifytextbyid" todir="${junit.output.dir}"/>
<classpath refid="SeleniumProject.classpath"/>
</junit>
</target>
<target name="verifytitle (1)">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="verifytitle" todir="${junit.output.dir}"/>
<classpath refid="SeleniumProject.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
AND THIS IS THE OUTPUT OF THE CONSOLE:
Buildfile: C:\Users\Roshan\workspace\SeleniumProject\build.xml
build-subprojects:
init:
build-project:
[echo] SeleniumProject: C:\Users\Roshan\workspace\SeleniumProject\build.xml
[javac] C:\Users\Roshan\workspace\SeleniumProject\build.xml:78: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
build:
junitreport:
[junitreport] Processing C:\Users\Roshan\workspace\SeleniumProject\junit\TESTS-TestSuites.xml to C:\Windows\null231041511
[junitreport] Loading stylesheet jar:file:/C:/apache-ant-1.9.4-bin/apache-ant-1.9.4/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] Failed to process C:\Users\Roshan\workspace\SeleniumProject\junit\TESTS-TestSuites.xml
BUILD FAILED
C:\Users\Roshan\workspace\SeleniumProject\build.xml:143: Errors while applying transformations: java.io.FileNotFoundException: C:\Windows\null231041511 (Access is denied)
Total time: 942 milliseconds
The Junit tests are run in the absolutexpath and relativexpath targets. i don't see either of those in "depends" attributes. Your output implies they aren't run either.
Also, you get the message:
C:\Windows\null231041511 (Access is denied)
Can you point to a directory that you have read and write access to like c:\temp?
How can I generate HTML reports from JUnit using Ant when there are test failures?
The reports are generated when there are no failures.
Also, how can we define our own XSLT for the report generation?
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="Ant Example" default="all" basedir=".">
<property name="project_name" value="junitSamples" />
<property name="src" location="src" />
<property name="build" location="build/classes" />
<property name="lib" location="lib" />
<property name="reports" location="reports" />
<target name="init" depends="clean">
<mkdir dir="${build}" />
<mkdir dir="${lib}" />
<mkdir dir="${reports}" />
<mkdir dir="${reports}/raw/" />
<mkdir dir="${reports}/html/" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${build}" description="compile the source code ">
<classpath>
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="clean">
<delete dir="build" />
<delete dir="${reports}" />
</target>
<target name="run-tests" depends="compile">
<junit printsummary="yes" haltonfailure="yes" showoutput="yes">
<classpath>
<pathelement path="${build}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
<batchtest fork="yes" todir="${reports}/raw/">
<formatter type="xml" />
<fileset dir="${src}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="test" depends="run-tests">
<junitreport todir="${reports}">
<fileset dir="${reports}/raw/">
<include name="TEST-*.xml" />
</fileset>
<report format="noframes" todir="${reports}\html\" />
</junitreport>
</target>
<target name="all" depends="clean, test" />
</project>
To specify your own stylesheets, use the "styledir" attribute:
<report styledir="${resources}/junit" format="..." todir="..." />
As noted, you must use the "junit-noframes.xsl" stylesheet name.
JUnit report docs.
You set haltonfailure="yes" it means that if one test fails build operation will stop.
This is from the ant documentation:
"Stop the build process if a test fails (errors are considered failures as well)."
Read more here- https://ant.apache.org/manual/Tasks/junit.html
A project's building process is suffering, unless it becomes automatic.
I have started with ANTLR since recently. ANT seems to be the very building tool for that purpose. Compile, jar, and test... But I have found little code source of the script build.xml for that purpose.
So would you guys would like to share your template build.xml for your antlr project (either Java task or ANTLR task will be fine)? Thanks.
This is roughly what I use:
<?xml version="1.0" encoding="UTF-8"?>
<project name="YourProject">
<property name="main.package" value="yourproject"/>
<property name="parser.package" value="${main.package}/parser"/>
<property name="main.src.dir" value="src/main"/>
<property name="test.src.dir" value="src/test"/>
<property name="grammar.src.dir" value="src/grammar"/>
<property name="grammar.file" value="${grammar.src.dir}/YourGrammar.g"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="main.build.dir" value="${classes.dir}/main"/>
<property name="test.build.dir" value="${classes.dir}/test"/>
<path id="classpath">
<pathelement location="${main.src.dir}"/>
<pathelement location="${test.src.dir}"/>
<pathelement location="${main.build.dir}"/>
<pathelement location="${test.build.dir}"/>
<!-- the ANTLR jar is in the lib directory, of course -->
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
</path>
<!-- init target -->
<target name="compile" depends="init" description="Compiles all source files.">
<javac srcdir="${main.src.dir}" destdir="${main.build.dir}" includeantruntime="false">
<classpath refid="classpath"/>
</javac>
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" includeantruntime="false">
<classpath refid="classpath"/>
</javac>
</target>
<target name="generate" depends="init" description="Generates the lexer and parser from the .g grammar file.">
<echo>Generating the lexer and parser...</echo>
<java classname="org.antlr.Tool" fork="true" failonerror="true">
<arg value="-fo"/>
<arg value="${main.src.dir}/${parser.package}"/>
<arg value="${grammar.file}"/>
<classpath refid="classpath"/>
</java>
<!--
compile the generated parser and lexer source file to see
if there's no illegal code inside these source files
-->
<antcall target="compile"/>
</target>
<!-- other targets -->
</project>
Here's the core pieces of mine, which I think integrates a little better. I'm not sure when ANTLR's -make option was added--I'm using 3.2.
It assumes that grammars are kept in the packages where their generated parsers will be going.
Keeps generated source files separate from normal source files so that they can be cleaned
Only regenerates parser+lexer sources when they are older than grammar file
multiple grammars can be processed in a single pass
ANTLR errors are reported correctly by ant
<project name="MyProject">
<property name="lib.antlr" value="lib/antlr-3.2.jar" />
<property name="src.dir" value="${user.dir}" />
<property name="src.java" value="${src.dir}/java" />
<property name="build.dir" value="build" />
<property name="build.src" value="${build.dir}/src" />
<property name="build.classes" value="${build.dir}/classes" />
<path id="compile.class.path">
<pathelement location="${build.classes}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${reports.dir}" />
</target>
<target name="generate" description="Generate parsers from ANTLR grammars">
<mkdir dir="${build.src}" />
<java jar="${lib.antlr}" fork="true" dir="${src.java}" failonerror="true">
<arg value="-verbose" />
<arg value="-make" />
<arg value="-o" />
<arg path="${build.src}" />
<arg value="com/example/io/Foo.g" />
<arg value="com/example/text/Bar.g" />
</java>
</target>
<target name="compile" depends="generate">
<property name="javac.debug" value="on" />
<mkdir dir="${build.dir}" />
<mkdir dir="${build.classes}" />
<javac destdir="${build.classes}" source="1.6" target="1.6" includeantruntime="false" debuglevel="lines,vars,source">
<src path="${src.java}" />
<src path="${build.src}" />
<include name="com/example/**/*.java" />
<classpath refid="compile.class.path"/>
</javac>
</target>
</project>
You can also look at How to use ant with ANTLR3.
All of my reports get generated, but my coverage shows as 0%. I even created one dummy test to make sure it wasn't the way my tests were written, and it doesn't show for the one dummy class I'm covering. Here is my Ant build for this:
<?xml version="1.0" encoding="UTF-8" ?>
<project name="My Project Name" default="run.cobertura" basedir=".">
<description>My Description</description>
<!-- target: init -->
<target name="init">
<!-- create properties and directory structure -->
<property name="src.path" value="${basedir}/src" />
<property name="lib.path" value="${basedir}/lib" />
<property name="output.path" value="${basedir}/bin" />
<property name="testcase-unit-only.path" value="${basedir}/testcase-unit-only" />
<property name="testcase-unit-only.output.path" value="${basedir}/test-classes" />
<property name="cobertura.lib.path" value="${basedir}/lib-cobertura" />
<property name="cobertura.path" value="${basedir}/cobertura" />
<property name="cobertura.output.path" value="${cobertura.path}/bin" />
<property name="cobertura.reports.path" value="${cobertura.path}/reports" />
<property name="cobertura.data.file" value="${cobertura.path}/cobertura.ser" />
<delete dir="${testcase-unit-only.output.path}" />
<delete dir="${cobertura.path}"/>
<mkdir dir="${testcase-unit-only.output.path}"/>
<mkdir dir="${cobertura.path}"/>
<mkdir dir="${cobertura.output.path}"/>
<!-- define classpath references -->
<path id="cp.lib.path">
<fileset dir="${lib.path}">
<include name="*.jar"/>
</fileset>
</path>
<path id="cp.classes.path">
<pathelement path="${output.path}" />
</path>
<path id="cp.classes.test.path">
<pathelement path="${testcase-unit-only.output.path}" />
</path>
<path id="cp.lib.cobertura.path">
<fileset dir="${cobertura.lib.path}">
<include name="*.jar"/>
</fileset>
</path>
<path id="cp.all.path">
<path refid="cp.lib.path"/>
<path refid="cp.classes.path"/>
<path refid="cp.lib.cobertura.path"/>
</path>
</target>
<!-- target: run.cobertura-instrument -->
<target name="run.cobertura-instrument">
<taskdef classpathref="cp.lib.cobertura.path" resource="tasks.properties"/>
<cobertura-instrument todir="${cobertura.output.path}" datafile="${cobertura.data.file}">
<fileset dir="${output.path}">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
</target>
<!-- target: compile.classes -->
<target name="compile.classes">
<javac srcdir="${src.path}" destdir="${output.path}">
<classpath refid="cp.lib.path"/>
</javac>
</target>
<!-- target: compile.tests -->
<target name="compile.tests">
<javac srcdir="${testcase-unit-only.path}" destdir="${testcase-unit-only.output.path}">
<classpath refid="cp.all.path"/>
</javac>
</target>
<!-- target: run.junit -->
<target name="run.junit">
<junit fork="true" dir="${basedir}" failureProperty="test.failed">
<classpath location="${cobertura.output.path}"/>
<classpath location="${output.path}"/>
<sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.data.file}" />
<classpath refid="cp.lib.path"/>
<classpath refid="cp.classes.test.path"/>
<classpath refid="cp.lib.cobertura.path"/>
<formatter type="xml" />
<!-- <formatter type="brief" usefile="false"/> -->
<batchtest todir="${testcase-unit-only.output.path}" unless="testcase">
<fileset dir="${testcase-unit-only.output.path}">
<include name="**/*UnitTest.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- target: run.cobertura -->
<target name="run.cobertura" depends="init,run.cobertura-instrument,compile.classes,compile.tests,run.junit">
<cobertura-report srcdir="src" destdir="${cobertura.reports.path}" datafile="${cobertura.data.file}"/>
</target>
</project>
One thing I notice is that in the depends list for the run.cobertura target you instrument the compiled classes before you compile them. That might work if you run twice, assuming the compiled classes from the first run are not cleared down, but doesn't seem quite right. On the first run if there are no instrumented classes, your report would be empty.
I had the same ant build scripts. It worked on my local workstation, but didn't on jenkins server.
But server had jdk 7 and workstation jdk6. After changing jdk on jenkins server to jdk6, code coverage generates without any problem.
you must set debug on when you compile java
<javac **debug="on"** srcdir="${testcase-unit-only.path}" destdir="${testcase-unit-only.output.path}">
I have an ant script that I am trying to run my junit test from. It runs all but the junit portion of the ant with no errors. Anyone know why it's not hitting this portion of my script?
<?xml version="1.0"?>
<property file="build.properties" />
<property name="test.class.name" value="edu.psu.ist.probability.TestProbability" />
<path id="test.classpath">
<pathelement location="${classes}" />
<pathelement location="/lib/junit.jar" />
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef resource="checkstyletask.properties" classpath="${checkstyle}" />
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath>
<pathelement path="${findbugs.jar}" />
</classpath>
</taskdef>
<!--
Encapsulates the process of starting up program.
-->
<target name="run" depends="build">
<echo>-----------RUN-----------</echo>
<java classname="${main}" fork="true">
<!-- fork needed for running on OS X -->
<classpath>
<pathelement location="${jar}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</java>
</target>
<!--
Encapsulates the process of packaging (jarring) program.
-->
<target name="build" depends="document">
<echo>---------BUILD--------</echo>
<jar destfile="${jar}" basedir="${classes}" />
</target>
<!--
Encapsulates the process of generating javadoc for program.
-->
<target name="document" depends="findbugs">
<echo>-------DOC--------</echo>
<javadoc sourcepath="${src}" defaultexcludes="yes" destdir="${docs}" executable="C:\Program Files (x86)\Java\jdk1.6.0_20\bin\javadoc.exe" author="true" version="true" use="true" windowtitle="Decisions API">
</javadoc>
</target>
<!--
Encapsulates the process of executing findbugs against program.
-->
<target name="findbugs" depends="style">
<echo>----------FINDBUGS----------</echo>
<findbugs home="${findbugs}" output="html" outputFile="${findbugs.output}" failOnError="true" stylesheet="fancy.xsl">
<auxClasspath>
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</auxClasspath>
<sourcePath path="${src}"/>
<class location="${classes}" />
</findbugs>
</target>
<!--
Encapsulates the process of style-checking program.
-->
<target name="style" depends="compile">
<echo>---STYLE---</echo>
<checkstyle config="${checkstyleconfig}" classpath="${classes}">
<fileset dir="${src}" includes="**/*.java"
excludes="**/DecisionsProgram.java, **/*Test.java" />
</checkstyle>
</target>
<!--
Encapsulates the process of compiling program.
-->
<target name="compile" depends="clean">
<echo>------------COMPILE--------</echo>
<javac destdir="${classes}">
<src path="${src}" />
<classpath>
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<!--
Encapsulates the process of cleaning up program directory structure.
-->
<target name="clean">
<!-- make sure dirs exist first, to prevent error -->
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${docs}" />
<mkdir dir="${reports}" />
<!-- now delete them -->
<delete dir="${classes}" />
<delete dir="${dist}" />
<delete dir="${docs}" />
<delete dir="${reports}" />
<!-- now recreate them so they can be used -->
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${docs}" />
<mkdir dir="${reports}" />
</target>
<target name="test" depends="compile">
<echo>-------JUNIT----------</echo>
<junit fork="yes" haltonfailure="yes">
<test name="${test.class.name}" />
<formatter type="plain" usefile="false" />
<classpath refid="test.classpath" />
</junit>
</target>
There is no target which is invoking "test".
One possibility is to replace
<target name="style" depends="compile">
with
<target name="style" depends="test">