I want to know if the service test classes should use real DAO objects and connect to the database or it should use mock objects to test only the business logic it do?
Asked
Active
Viewed 1,600 times
2 Answers
5
Your test classes shouldn't connect to the database if you are testing only the business logic, you should use mocks instead.
This way is faster since the tests don't open and close connections and database independent ( you can run the tests without any database. )
If you want to test the DAO objects and the connections to the database then you should have other tests doing that.

Thanos Papathanasiou
- 2,462
- 1
- 20
- 22