It's not a secret anymore!*
The moose likes Testing and the fly likes JUnit Test Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit Test Query" Watch "JUnit Test Query" New topic
Author

JUnit Test Query

Karthik Sanghvi
Greenhorn

Joined: Nov 06, 2006
Posts: 9
Hello, I have a Implementation Class AccountServiceImpl.java



that implements accountService interface.






I want to write a JUnit test to test the credit limit at the time of withdrawal for any account.


Please help
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What's stopping you? What do you have so far?

Because you've coded to an implementation, the DAO isn't injectable. If you want to make the service testable, the DAO should be mockable such that you can test *just* the logic in the withdraw() method.

(I know it's just an example, or at least I assume it is, but the credit limit logic is (a) hardcoded, and (b) likely in the wrong place.)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JUnit Test Query
 
Similar Threads
Objects and Classes
Hey Can anyone help me with this
JUnit Testing Problem
JUnit Testing Problem
Basic Query in Spring