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 Is this a stub, mock, or fake? 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 "Is this a stub, mock, or fake?" Watch "Is this a stub, mock, or fake?" New topic

Is this a stub, mock, or fake?

Greg Charles

Joined: Oct 01, 2001
Posts: 2833

I'm working on a client/server application that uses a class DbAccess to manage a database connection. The basic interface:

That's not exactly how I would design it, but for now I need to live with it.

The openConnection() method gets a connection from a DataSource configured and maintained by the app server. I've made a subclass that overrides openConnection() to make a one-off connection to the database via the DriverManager instead, and I'm using this for various outside-of-the-container testing. Would I call this subclass a fake, stub, or mock? I think fake is the right term, but I'd like an expert opinion.

Let's say now that I also have a subclass of DbAccess that returns a fake (or mock or stub) ResultSet, which reads data out of text files and bypasses the database altogether. I'm struggling coming up with good names for these classes. How about DbAccessConnectionFake and DbAccessDataFake / ResultSetDataFake? I'm not liking that a lot.
I agree. Here's the link:
subject: Is this a stub, mock, or fake?
Similar Threads
how do I return a DBAccess interface back to client?
Putting ResultSet into an Array list
Finding out the correct URL
database connections
Testing Database Connection