junit ant task failing?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   james_none
Posted On:   Wednesday, October 19, 2005 11:34 AM

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 ...and the test case is this. package mock.accountExample; import junit.framework.TestC   More>>

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


			









...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{

public TestAccountService(String name){
super(name);
}

/**
*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() );

}
}

   <<Less

Re: junit ant task failing?

Posted By:   Roseanne_Zhang  
Posted On:   Wednesday, October 19, 2005 06:08 PM

Why did you put your JUnit testing classes as inner classes?


I think you'd better follow the conventions.


Creativeness is good, as long as it works...

About | Sitemap | Contact