Ant fails to find junit for project generated with wsdl2java - ant

I created a axis2 soap client project with unit tests using the following command:
wsdl2java -t -uri http://myDomain.tld/myService.svc?wsdl
I then ran ant and got build errors because it could not find junit methods such as fail(),assertNotNull(), etc. I realize I need the compiler to reference a junit jar. Looking in the build.xml I see the following:
<property name="classes" value="${build}/classes"/>
<property name="lib" value="${build}/lib"/>
So I place junit-4.8.2.jar in the build.lib subfolder. I still get the same errors. What else do I need to do to get ant to build my project?
Update:
I made the following changes to the build.xml:
Added the lib folder as a path with the id local.class.path
<path id="local.class.path">
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</path>
Then I modified my init task to look for junit:
<available classpathref="local.class.path" property="junit.available" classname="junit.framework.TestCase"/>
<condition property="jars.ok">
<and>
<isset property="stax.available"/>
<isset property="axis2.available"/>
<isset property="junit.available"/>
</and>
</condition>
<!--Print out the availabilities-->
<echo message="Stax Availability= ${stax.available}"/>
<echo message="Axis2 Availability= ${axis2.available}"/>
<echo message="JUnit Availability= ${junit.available}"/>
And strangely the output is:
H:\Code\Java\test.axis2> ant pre.compile.test
Buildfile: H:\Code\Java\RiskTools.axis2\build.xml
init:
[mkdir] Created dir: H:\Code\Java\test.axis2\build
[mkdir] Created dir: H:\Code\Java\test.axis2\build\classes
[mkdir] Created dir: H:\Code\Java\test.axis2\build\lib
pre.compile.test:
[echo] Stax Availability= true
[echo] Axis2 Availability= true
[echo] JUnit Availability= ${junit.available}
BUILD SUCCESSFUL
Total time: 0 seconds
So it seems I am doing something wrong due to the line [echo] JUnit Availability= ${junit.available}

Apparently build/lib is the transient folder that gets blown away by ant clean. I made a folder called lib at the project root and then did the following to the build.xml.
In the root I added <property name="dep_libs" value="${project.base.dir}/lib"/>
I then change my path statement above to:
<path id="local.class.path">
<fileset dir="${dep_libs}">
<include name="*.jar"/>
</fileset>
</path>
Then everything worked.

Related

ANT Script to deploy a War file in MobileFirst Server to create run time

I am using Ant script to deploy a war file in mobile first server to create run time. But I am not sure about the ANT Script, I am getting errors regarding database configuration.
This is the error I am getting by running Ant Script:
Building project
command: 'C:\Program Files\agent\opt\apache-ant-1.8.4\bin\ant.bat' -f 'C:\Program Files\agent\var\work\MF-Component\wardeploy.xml'
Buildfile: C:\Program Files\agent\var\work\MF-Component\wardeploy.xml
install:
[configureapplicationserver] Logging output of task <configureApplicationServer> to file C:\Users\miracle\Documents\IBM MobileFirst Platform Server Data\Configuration Logs\configureApplicationServer_2016_02_12_03_35_41.log
[configureapplicationserver] WARNING: The Reports database is deprecated in IBM MobileFirst Platform Foundation since V7.0.0.
[configureapplicationserver] Use Operational Analytics instead.
[configureapplicationserver] See http://ibm.biz/knowctr#SSHS8R_7.1.0/com.ibm.worklight.monitor.doc/monitor/c_op_analytics_overview.html
BUILD FAILED
C:\Program Files\agent\var\work\MF-Component\wardeploy.xml:33: Element <db2> inside <database kind="Worklight"> inside <configureApplicationServer>: Database does not contain the expected tables. The test table GADGET_USER_PREF was not found.
You may create the required tables through an invocation of <configureDatabase>.
Total time: 4 seconds
Caught: com.urbancode.air.ExitCodeException: Command failed with exit code: 1
com.urbancode.air.ExitCodeException: Command failed with exit code: 1
at com.urbancode.air.CommandHelper.runCommand(CommandHelper.groovy:195)
at com.urbancode.air.CommandHelper$runCommand$0.callCurrent(Unknown Source)
at com.urbancode.air.CommandHelper.runCommand(CommandHelper.groovy:121)
at com.urbancode.air.CommandHelper$runCommand.call(Unknown Source)
at ant.run(ant.groovy:123)
Here I don't need any tables to deploy the war file but it was asking for table. For deploying the war file it needs to have database. That I have given the credentials but it shows some errors as above.
Here Is the Ant script I am using.
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="install">
<taskdef resource="com/worklight/ant/deployers/antlib.xml">
<classpath>
<pathelement location="C:\Program Files\IBM\MobileFirst_Platform_Server\WorklightServer\worklight-ant-deployer.jar"/>
</classpath>
</taskdef>
<target name="databases">
<configuredatabase kind="Worklight">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4">
</db2>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</configuredatabase>
<configuredatabase kind="WorklightReports">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4">
</db2>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</configuredatabase>
</target>
<target name="install">
<configureapplicationserver>
<project warfile="C:\Program Files\agent\var\work\MF-Component\bin\Git_Demo.war" libraryfile="C:\Program Files\IBM\MobileFirst_Platform_Server\WorklightServer\worklight-jee-library.jar"/>
<!-- Here you can define values which override the
default values of Worklight configuration properties -->
<property name="serverSessionTimeout" value="10"/>
<applicationserver>
<websphereapplicationserver installdir="C:\Program Files\IBM\WebSphere\Liberty"
profile="Liberty"
user="admin" password="admin">
<server name="UCDServer"/>
</websphereapplicationserver>
</applicationserver>
<database kind="Worklight">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4"/>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</database>
<database kind="WorklightReports">
<db2 database="TESTDB" server="172.17.0.177" user="mobusr4" password="mobileuser4"/>
<driverclasspath>
<fileset dir="C:\Program Files\IBM\WebSphere\Liberty\usr\shared\resources\worklight_1\db2">
<include name="db2jcc4.jar"/>
<include name="db2jcc_license_*.jar"/>
</fileset>
</driverclasspath>
</database>
</configureapplicationserver>
</target>
</project>
This is correct, the WAR file needs to have a database. Before creating the datasource in the application server, the configuredatabase Ant task verifies that the datasource exists and has the correct tables. It didn't find it and failed with an error.
To create the database tables run the 'databases' target in your ant file.
For more information, see https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.deploy.doc/devref/c_project_war_file_ant_tasks.html

Use pure Ant to search if list of files exists and take action based on condition

User passes a list of files in an XML file, below will be the sample:
<property-bundle name = "abc">
<action>clean</action>
<target-location>/vst/property/pog/</target-location>
<file-name>test1.props</file-name>
<file-name>test2.props</file-name>
<file-name>test3.props</file-name>
</property-bundle>
Now based on that action remove, I have to incorporate logic in build.xml to delete the files in the directory , but for that I want to perform a validation only if the file exists then remove or else throw the build failure error. I was able to read the values from the user input XML and takes those files into a file list property
<property name="file.list" value="test1.props,test2.props,test3.props"/>
<target name = "clean">
<delete>
<fileset dir="${target.location}" includes = "${file.list}"/>
</delete>
</target>
but with the clean target it only validates if the directory exists since it is fileset but does not do the validation if file exists , I read that filelist does validation for file exists but filelist can work with delete.
Since we are using Ant 1.6.5 in our environment I can not use antcontrib , It takes whole lot of process and approvals to upgrade Ant now , Can you please guide me on how it can be achieved with the pure Ant.
You should be able to just use delete's #failonerror attribute which throws an error if the file cannot be deleted.
<target name = "clean">
<delete failonerror="true">
<fileset dir="${target.location}" includes="${file.list}"/>
</delete>
</target>
The above will delete files and then error when it doesn't find a file, leaving you in a partially deleted state. If you want to avoid partial deletions, you can run another task to check first
<target name="failIfMissing">
<copy failonerror="true" todir="${temp.directory}">
<fileset dir="${target.location}" includes="${file.list}"/>
</copy>
</target>
by attempting to copy to a temporary directory, failing if some of the target files did not exist.
It is possible to loop over files with Ant-Contrib Tasks and then it will look something like this:
<target name="clean">
<foreach target="delete.if.exists" param="fileName">
<fileset dir="${target.location}" includes="${file.list}"/>
</foreach>
</target>
<target name="delete.if.exists">
<delete failonerror="true" file="$fileName"/>
</target>
Folks,
Thank you all for your outstanding help & contributions , I have finally achieved this with below
<target name="validate.file" depends="defineAntContribTasks,validate.dir">
<echo message=" The value of the filelist is ::::::::::::: ${file.list} :::::::::::::::::: "/>
<for param="file" list="${file.list}">
<sequential>
<if>
<available file="${target.location}/#{file}"/>
<then>
<echo message = "File::: #{file} ::::is valid , Found in :::${target.location}::: "/>
</then>
<else>
<fail message=" File::: #{file} ::::is not valid ,it is not found in :::${target.location}::: ,plesae recheck and submit again"/>
</else>
</if>
</sequential>
</for>
</target>
Thanks again for all of your valuable time and guidance.
<target name="removeUnwantedFiles" description="delete the build destination tree to ensure that it will contain ONLY what is explicitly needed for a build and ONLY what is intended to be release.">
<delete>
<fileset dir="${project-home}">
<includesfile name="${scripts}/excludeJavaFilesForV1.txt"/>
</fileset>
</delete>
</target>
This works for me.. hope this helps..
Ant is not a programming language and therefore has no native looping mechanism. In the absence of external plugins a trick that can used is an XSL transformation. Process the input XML file into a Ant script which implements the desired operation on each file.
Example
├── build.xml
├── files-process.xsl
├── files.xml <-- Input listed above
├── test1.props
├── test2.props
└── test3.props
Run the build and the files listed in "files.xml" are deleted:
build:
[delete] Deleting: /home/mark/tmp/test1.props
[delete] Deleting: /home/mark/tmp/test2.props
[delete] Deleting: /home/mark/tmp/test3.props
Run the build a second time and an error is generated:
BUILD FAILED
/home/mark/tmp/build.xml:6: The following error occurred while executing this line:
/home/mark/tmp/build-tmp.xml:4: file not found: test1.props
build.xml
Use the xslt task to generate a temporary Ant script containing the desired file deletion logic:
<project name="demo" default="process-files">
<target name="process-files">
<xslt style="files-process.xsl" in="files.xml" out="build-tmp.xml"/>
<ant antfile="build-tmp.xml"/>
</target>
<target name="clean">
<delete file="build-tmp.xml"/>
</target>
</project>
files-process.xsl
The following stylesheet generates an Ant script:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<project name="genbuild" default="build">
<target name="build">
<xsl:apply-templates select="property-bundle/file-name"/>
</target>
</project>
</xsl:template>
<xsl:template match="file-name">
<available file="{.}" property="{generate-id()}.exists"/>
<fail message="file not found: {.}" unless="{generate-id()}.exists"/>
<delete file="{.}" verbose="true"/>
</xsl:template>
</xsl:stylesheet>
build-tmp.xml
To aid readability I have formatted the generated Ant script:
<project name="genbuild" default="build">
<target name="build">
<available file="test1.props" property="N65547.exists"/>
<fail message="file not found: test1.props" unless="N65547.exists"/>
<delete file="test1.props" verbose="true"/>
<available file="test2.props" property="N65550.exists"/>
<fail message="file not found: test2.props" unless="N65550.exists"/>
<delete file="test2.props" verbose="true"/>
<available file="test3.props" property="N65553.exists"/>
<fail message="file not found: test3.props" unless="N65553.exists"/>
<delete file="test3.props" verbose="true"/>
</target>
</project>
Note:
Properties in Ant are immutable, so I used the XSL generate-id() function to create a unique property name.
Software used
This example was tested with the following software versions:
$ ant -version
Apache Ant version 1.6.5 compiled on June 2 2005
$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

How to execute Ant build in command line

I have an Ant build file, and I try to execute it in the command line with the following command:
$ C:\Program Files (x86)\.....>ant -f C:\Silk4J\Automation\iControlSilk4J\build.xml
But nothing happens, and the result is:
BUILD SUCCESSFUL
Total time: 0 seconds
My environment variable is correct.
What is the problem? Here is my build file:
<?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="iControlSilk4J">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../Program Files (x86)/Silk/SilkTest/eclipse"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<path id="Silk Test JTF 13.5.0 Library.libraryclasspath">
<pathelement location="../../../Program Files (x86)/Silk/SilkTest/ng/JTF/silktest-jtf-nodeps.jar"/>
</path>
<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="iControlSilk4J.classpath">
<pathelement location="bin"/>
<pathelement location="lib/apache-log4j.jar"/>
<pathelement location="lib/commons-io-2.4.jar"/>
<pathelement location="lib/commons-lang3-3.1.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="lib/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
<pathelement location="lib/silktest-jtf-nodeps.jar"/>
<path refid="Silk Test JTF 13.5.0 Library.libraryclasspath"/>
<path refid="JUnit 4.libraryclasspath"/>
<pathelement location="../../../Users/Admin/Desktop/java-mail-1.4.4.jar"/>
<pathelement location="../../../Users/Admin/Desktop/javax.activation.jar"/>
<pathelement location="lib/joda-time-2.3.jar"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<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="iControlSilk4J.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"/>
...
Go to the Ant website and download. This way, you have a copy of Ant outside of Eclipse. I recommend to put it under the C:\ant directory. This way, it doesn't have any spaces in the directory names. In your System Control Panel, set the Environment Variable ANT_HOME to this directory, then pre-pend to the System PATHvariable, %ANT_HOME%\bin. This way, you don't have to put in the whole directory name.
Assuming you did the above, try this:
C:\> cd \Silk4J\Automation\iControlSilk4J
C:\Silk4J\Automation\iControlSilk4J> ant -d build
This will do several things:
It will eliminate the possibility that the problem is with Eclipe's version of Ant.
It is way easier to type
Since you're executing the build.xml in the directory where it exists, you don't end up with the possibility that your Ant build can't locate a particular directory.
The -d will print out a lot of output, so you might want to capture it, or set your terminal buffer to something like 99999, and run cls first to clear out the buffer. This way, you'll capture all of the output from the beginning in the terminal buffer.
Let's see how Ant should be executing. You didn't specify any targets to execute, so Ant should be taking the default build target. Here it is:
<target depends="build-subprojects,build-project" name="build"/>
The build target does nothing itself. However, it depends upon two other targets, so these will be called first:
The first target is build-subprojects:
<target name="build-subprojects"/>
This does nothing at all. It doesn't even have a dependency.
The next target specified is build-project does have code:
<target depends="init" name="build-project">
This target does contain tasks, and some dependent targets. Before build-project executes, it will first run the init target:
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
This target creates a directory called bin, then copies all files under the src tree with the suffix *.java over to the bin directory. The includeemptydirs mean that directories without non-java code will not be created.
Ant uses a scheme to do minimal work. For example, if the bin directory is created, the <mkdir/> task is not executed. Also, if a file was previously copied, or there are no non-Java files in your src directory tree, the <copy/> task won't run. However, the init target will still be executed.
Next, we go back to our previous build-project target:
<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="iControlSilk4J.classpath"/>
</javac>
</target>
Look at this line:
<echo message="${ant.project.name}: ${ant.file}"/>
That should have always executed. Did your output print:
[echo] iControlSilk4J: C:\Silk4J\Automation\iControlSilk4J\build.xml
Maybe you didn't realize that was from your build.
After that, it runs the <javac/> task. That is, if there's any files to actually compile. Again, Ant tries to avoid work it doesn't have to do. If all of the *.java files have previously been compiled, the <javac/> task won't execute.
And, that's the end of the build. Your build might not have done anything simply because there was nothing to do. You can try running the clean task, and then build:
C:\Silk4J\Automation\iControlSilk4J> ant -d clean build
However, Ant usually prints the target being executed. You should have seen this:
init:
build-subprojects:
build-projects:
[echo] iControlSilk4J: C:\Silk4J\Automation\iControlSilk4J\build.xml
build:
Build Successful
Note that the targets are all printed out in order they're executed, and the tasks are printed out as they are executed. However, if there's nothing to compile, or nothing to copy, then you won't see these tasks being executed. Does this look like your output? If so, it could be there's nothing to do.
If the bin directory already exists, <mkdir/> isn't going to execute.
If there are no non-Java files in src, or they have already been copied into bin, the <copy/> task won't execute.
If there are no Java file in your src directory, or they have already been compiled, the <java/> task won't run.
If you look at the output from the -d debug, you'll see Ant looking at a task, then explaining why a particular task wasn't executed. Plus, the debug option will explain how Ant decides what tasks to execute.
See if that helps.
Try running all targets individually to check that all are running correct
run ant target name to run a target individually
e.g. ant build-project
Also the default target you specified is
project basedir="." default="build" name="iControlSilk4J"
This will only execute build-subprojects,build-project and init
is it still actual?
As I can see you wrote <target depends="build-subprojects,build-project" name="build"/>, then you wrote <target name="build-subprojects"/> (it does nothing). Could it be a reason?
Does this <echo message="${ant.project.name}: ${ant.file}"/> print appropriate message? If no then target is not running.
Take a look at the next link http://www.sqaforums.com/showflat.php?Number=623277

Why won't ant run my unit tests correctly?

I'm trying to figure out how to set up a project using ant. For some reason, I can't get the junit tests to run. I set up a simple dummy project using ant to try and figure this out. All it has is a single unit test that should pass trivially.
My project structure looks like this.
.
|-- build.xml
|-- src
`-- test
|-- foo
| `-- MainTest.java
`-- junit-4.10.jar
MainTest.java looks like this.
package foo;
import org.junit.*;
import static org.junit.Assert.*;
public class MainTest {
#Test
public void passes() {
System.out.println("It works!");
}
}
And here is build.xml.
<project name="Nes" default="build" basedir=".">
<target name="build-test">
<javac srcdir="test">
<classpath>
<pathelement location="test/junit-4.10.jar" />
</classpath>
</javac>
</target>
<target name="test" depends="build-test">
<junit>
<classpath>
<pathelement location="test/junit-4.10.jar" />
</classpath>
<batchtest>
<fileset dir="test" includes="foo/MainTest.class" />
</batchtest>
</junit>
</target>
</project>
Here's the output I get from running ant test.
Buildfile: /home/hayden/dev/nes/build.xml
build-test:
[javac] /home/hayden/dev/nes/build.xml:4: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
test:
[junit] Test foo.MainTest FAILED
BUILD SUCCESSFUL
Total time: 0 seconds
I'm running ant 1.8.2 and Java 6.
What am I doing wrong?
You need to add a path to the actual .class file so JUnit can actually run the test. Since you are fully qualifying the test class name, you need to include the directory that contains the foo package:
<target name="test" depends="build-test">
<junit>
<classpath>
<pathelement location="test/junit-4.10.jar" />
<pathelement location="test" />
</classpath>
But I'd recommend that you change the javac task to not output build artifacts (i.e. .class files) into the same directory as your source files. Create a top-level "build" directory and put all your build output in there.
You should also quiet the first warning by adding a includeantruntime attribute to the javac task:
<javac srcdir="test" includeantruntime="false">

Making jUnit output info and compile to /build folder

I have the following Ant buildfile:
<?xml version="1.0"?>
<!-- the value of the default attr must be one of the targets. -->
<project name="Money" default="build-source" basedir=".">
<description>The Money project build file.</description>
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="junit" location="lib/junit-4.9b3.jar"/>
<path id="_classpath">
<pathelement path="${junit}"/>
<pathelement path="${build}"/>
</path>
<target name="prepare">
<mkdir dir="${build}"/>
</target>
<target name="build-source" depends="prepare"
description="compile the source ">
<javac srcdir="${src}" destdir="${build}">
<classpath refid="_classpath"/>
</javac>
</target>
<target name="run" depends="build-source">
<junit printsummary="on" showoutput="on">
<test name="money.MoneyTest"/>
<classpath refid="_classpath"/>
</junit>
</target>
</project>
It's pretty basic - I'm just trying to get this thing to run properly. What I don't get is: 1) Why does it output the compiled files to a /build/money directory? I want the output directory to be just /build, given this directory structure for my files:
build/
build.xml
lib/
src/
test/
2) When there are tests that don't pass, it says "Test money.MoneyTest FAILED". I'd like it to output info about the failure, expected / actual values, line number, etc.
I can't figure this out by staring at the buildfile above. Any advice?
It outputs the compiled files under build, creating a directory structure that corresponds to the layout of your packages.
Since you put your classes in the money package, the output will be under build/money. If you put your classes under a org.example.foo package, your output would be in the build/org/example/foo directory.
To have your .class files in build, you would have to use the default package.
Edit
I assume your source files have a package money; declaration, as in:
package money;
public class MoneyTest {
...
}
If you add a <formatter> element, detailed reports about test failures will be written to an output file (by default, named TEST-name). See also the Ant Junit Task Documentation.
<junit printsummary="withOutAndErr" showoutput="on">
<formatter type="plain"/>
<test name="money.MoneyTest"/>
<classpath refid="_classpath"/>
</junit>
I have not found a way to directly print the failed tests reports to standard output.

Resources