colliedunk1 (3) [Avatar] Offline
#1
Hi there,
I'm trying to run a test from an ant script and get the following error. Could someone help me figure what's wrong. Thanks.
[junit] Testcase: warning(junit.framework.TestSuite$1):     FAILED
[junit] Class mock.accountExample.TestAccountService has no public constructor TestCase(String name) or TestCase()
[junit] junit.framework.AssertionFailedError: Class mock.accountExample.TestAccountService has no public constructor TestCase(String name) or TestCase()


The ant task is as follows
<junit printsummary="yes" haltonfailure="yes" haltonerror = "yes "  fork = "yes" >
      <jvmarg value = "-client" />
      <classpath refid = "cp" />
      <formatter type="brief" usefile = "false" />
      <test name = "${test}" />
</junit>


...and the test case is this.

package mock.accountExample;

import junit.framework.TestCase;

        //I'm putting test cases as an inner class.
         class TestAccountService extends TestCase{

             /**
              *Tests the AccountService's transfer method
              */
             public void testTransferOK(){
                 // fail("I want this to fail.");
                MockAccountManager mockAccMngr = new MockAccountManager();
                 Account sndr = new Account("1", 200);
                 Account rcvr = new Account("2", 100);

                 mockAccMngr.addAccount("1", sndr);
                 mockAccMngr.addAccount("2", rcvr);

                 AccountService accSrv = new AccountService();

                 accSrv.setAccountManager( mockAccMngr );

                 accSrv.transfer("1", "2", 50);

                 assertEquals( 150, sndr.getBalance() );
                 assertEquals( 150, rcvr.getBalance() );

             }
        }
ErikHatcher (211) [Avatar] Offline
#2
Re: Problem with junit task
My hunch is that you're running an older version of JUnit.
colliedunk1 (3) [Avatar] Offline
#3
Re: Problem with junit task
I have a current release of junit, 3.8.1 I think.
I resolved the problem by declaring the class public.
Regards,
James.