Ant and JUnit.
I reduced the build.xml
file on my project drastically this morning (more than 900 lines). I used to have a task per testcase and was able to consolidate from this:
<!-- =================================================================== --> <!-- Run the UserDAO test --> <!-- =================================================================== --> <target name="test.userDAO" depends="compile"> <echo message="Running UserDAO Test -------------------"/> <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes"> <jvmarg value="-Djunit.conf=./src/onpoint/PersistenceTestValues.ini"/> <classpath> <pathelement path="${webapp.target}/WEB-INF/classes"/> </classpath> <classpath refid="classpath"/> <formatter type="plain" usefile="false"/> <test name="com.onpoint.webapp.persistence.UserDAOTest"/> </junit> </target>
To this:
<!-- =================================================================== --> <!-- Run all the Persistence tests --> <!-- =================================================================== --> <target name="test.persistence" depends="compile"> <echo message="Running Persistence Tests -------------------"/> <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes"> <jvmarg value="-Djunit.conf=./src/onpoint/PersistenceTestValues.ini"/> <classpath> <path refid="classpath"/> <pathelement path="${webapp.target}/WEB-INF/classes"/> </classpath> <formatter type="plain" usefile="false"/> <test name="com.onpoint.webapp.persistence.${testcase}" if="testcase"/> <batchtest unless="testcase"> <fileset dir="${webapp.target}/WEB-INF/classes" includes="**/persistence/*Test.class"/> </batchtest> </junit> </target>
And I got to remove the AllTests.java
file in the persistence package! You probably knew this already, but just in case...
Thanks to Erik Hatcher for Java Development with Ant. I studied this book for three hours yesterday and it's already increasing my productivity! I hope to finish it by tomorrow afternoon - only 300 pages to go. It's pretty cool when you're reading someone's book and getting e-mails from them at the same time.