File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Is this a stub, mock, or fake?" Watch "Is this a stub, mock, or fake?" New topic
Author

Is this a stub, mock, or fake?

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Is this a stub, mock, or fake?