This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit Test Query" Watch "JUnit Test Query" New topic

JUnit Test Query

Karthik Sanghvi

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

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

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.)
jQuery in Action, 2nd edition
subject: JUnit Test Query
Similar Threads
Hey Can anyone help me with this
JUnit Testing Problem
JUnit Testing Problem
Basic Query in Spring
Objects and Classes