20021017 Thursday October 17, 2002

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. Posted in General at Oct 17 2002, 04:37:09 AM MDT Add a Comment

Comments:

Post a Comment:
  • HTML Syntax: Allowed
Click me to subscribe
Matt Raible is a Web Architect who enjoys developing applications with open source technologies. Contact me for rates.
« December 2008
SunMonTueWedThuFriSat
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
   
       
Today

Recent Entries

Tag Cloud