Bug 3668 - A way to run just one TestCase
: A way to run just one TestCase
: Java WS Core
: unspecified
: All All
: P3 enhancement
: ---
Assigned To:
  Show dependency treegraph
Reported: 2005-08-19 07:27 by
Modified: 2005-09-16 15:50 (History)



You need to log in before you can comment on or make changes to this bug.

Description From 2005-08-19 07:27:03
To isolate a problem it was necessary to run just one TestCase from
RFTTest.java.  I found the approach documented here to be very useful:


This is the syntax to run just one test(in this case testDirTransfer):

 ant run_one -Dtests.jar=/opt/gt401f/lib/globus_wsrf_rft_test.jar -f
/opt/gt401f/share/globus_wsrf_rft_test/runtests.xml -Dtest=RFTTest.class

If you take the java code from TestUtils (which i renamed to TestUtil) and add
these headers, it will compile:

    package org.globus.transfer.reliable.service.test;

    import junit.framework.TestCase;
    import junit.framework.TestSuite;
    import java.util.StringTokenizer;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Iterator;

    import java.lang.reflect.Constructor;
    import java.lang.Object;

Then change the rft PackageTests suite method:
    public static Test suite() throws Exception {
        TestSuite suite = new PackageTests( "RFT Testing" );

        if ( TestUtil.hasTestCases() ) {
           return TestUtil.getSuite( RFTTest.class );
        suite.addTest( new TestSuite( RFTTest.class ) );
        suite.addTest( new TestSuite( RFTOptionsTest.class ) );
        return suite;

Then change share/globus_wsrf_rft_test/runtests.xml - add the following targets:

   <target name="_ensure-test-name" unless="test">
     <fail message="You must run this target with -Dtest=TestName"/>
   <target name="_runtest" description="Runs the test you specify on the command 
     line with -Dtest=" depends="_ensure-test-name">
     <junit printsummary="withOutAndErr" fork="yes"> 
         <sysproperty key="tests" value="${tests}"/>
         <sysproperty key="org.globus.wsrf.container.webroot" 
         <sysproperty key="GLOBUS_LOCATION" 
         <sysproperty key="package.name" 
                 <pathelement location="${abs.deploy.dir}"/>
                 <fileset dir="${abs.deploy.dir}/lib">
                     <include name="*.jar"/>
          <formatter type="plain" usefile="false"/>
              <fileset dir="${tests.dir}">
                  <patternset refid="test.fileset"/>
    <target name="run_one" 
             description="Executes tests contained in a jar file 
                          (in external container)"
       <property name="server.arg" value="-Dignore" />
       <antcall target="runTests_one"/>
     <target name="runTests_one" unless="securityTestsOnly">
       <patternset id="package.fileset">
          <include name="**/PackageTests.class" />
       <antcall target="_runtest">
           <reference refid="package.fileset" torefid="test.fileset"/>

  1) The ant targets are basically a copy of the current targets (like
runCustomTests) combined with the targets from the article.  I'm sure some
combination could be made to reduce redundancy.

2) I imagine that TestUtil could be improved/added to and some targets adjusted
such that there would be no need to code a PackageTest at all. But the approach
documented here at least doesn't impact any existing processes or documentation. 

3) You may not want TestUtil to be in the reliable.service.test package.

4) I do like the plain formatter and the fact that it dumps to output to stdout
in this case.  Seems like the correct output options when you are running one
------- Comment #1 From 2005-08-19 16:04:07 -------
We're going to consider adding this to the core testing framework.
------- Comment #2 From 2005-09-16 15:50:34 -------
I added support for running a specific set of test cases at a time. It's part 
of the Java WS Core testing framework. The new test targets are called 'runOne' 
and 'runOneServer'. Both take the same arguements:

1) '-Dtest.class=<class name>' - specifies the class that has the test suite. 
It's required.

2) '-Dtests=<testCase1[,testCaseN]>' - specifies a set of specific test cases 
to execute (comma-separated list). It is optional. If not specified, all tests 
cases are executed. 


> ant -f share\globus_wsrf_test\runtests.xml runOne 

This will work properly if the org.globus.wsrf.test.FilteredTestSuite is used 
instead of the junit.framework.TestSuite. GridTestSuite now inherits from the 
FilteredTestSuite. Not everything has been updated yet to use the new