You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by th...@se.abb.com on 2002/08/12 09:31:20 UTC

Peculiar behaviour of junit task

Hi everybody!

When I run my JUnit testcases via the IDE (eclipse) both as applications
and as JUnit test everything works well.
But when I run them (i.e. testcases) via ant my assertion code fails. Here
is some java code:

     public GenericPoolMetaData metaData;
     public IXElementPool pool;

     /**
      * @see TestCase#setUp()
      */
     protected void setUp() throws Exception
     {
          //super.setUp();
          metaData = new GenericPoolMetaData();
          metaData.setDebugging(false);
          metaData.setMaximumSize(10);
          metaData.setMinimumSize(5);
          metaData.setInitialObjects(5);
          metaData.setName("pool");

          pool = new IXElementPool(metaData);

     }


     public void testRequestingElements()
     {
          this.assertNotNull(pool);
          this.assertEquals("pool", pool.getPoolname());
          System.out.println(pool.numCheckedInObjects()); // Just a
confirmation.
          this.assertEquals(5, pool.numCheckedInObjects());
          this.assertEquals(0, pool.numCheckedOutObjects());

          IXElement element = (IXElement) pool.requestObject();
          this.assertNotNull(element);
          this.assertEquals(4, pool.numCheckedInObjects());
          this.assertEquals(1, pool.numCheckedOutObjects());
     }

Here is the ant code:

      <junit printsummary="true">
        <formatter type="xml" />
        <classpath>
          <pathelement path="${classes.dir}" />

          <fileset dir="${lib.dir}">
            <exclude name="xerces.jar"/>
            <exclude name="crimson.jar"/>
            <include name="**/*.jar"/>
          </fileset>

          <fileset dir="${ext.dir}">
            <include name="**/*.jar"/>
          </fileset>
        </classpath>
        <!-- All tests -->
        <test name="test.com.abbmcls.xml.util.IXElementPoolTest" />
      </junit>

      <junitreport todir="./report">
        <fileset dir="./">
          <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="./report" />
      </junitreport>

When I run it via ant the test for number of checked in objects (pool.numCheckedInObjects()) will fail asserting that
the expected result is 5 but the actual is 0.

Any idea?

Thanks in advance,

/Theis.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>