Test Doubles : Do they go in "source packages" or "test packages"?

Posted by sbrattla on Programmers See other posts from Programmers or by sbrattla
Published on 2013-10-20T19:46:36Z Indexed on 2013/10/20 22:10 UTC
Read the original article Hit count: 216

Filed under:
|
|
|

I've got a couple of data access objects (DefaultPersonServices.class, DefaultAddressServices.class) which is responsible for various CRUD operations in a database.

A few different classes use these services, but as the services requires that a connection is established with a database I can't really use them in unit tests as they take too long. Thus, I'd like to create a test doubles for them and simply do FakePersonServices.class and FakeAddressService.class implementations which I can use throughout testing.

Now, this is all good (I assume)...but my question relates to where I put the test doubles. Should I keep them along with the default implementations (aka "real" implementations) or should I keep them in a corresponding test package.

The default implementations are found in Source Packages : com.company.data.services. Should I keep the test doubles here too, or should the test doubles rather be in Test Packages : com.company.data.services?

© Programmers or respective owner

Related posts about java

Related posts about testing