File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.)
I agree. Here's the link:
subject: JUnit Test Query
It's not a secret anymore!