jeudi 15 septembre 2016

Junit test the Business class that invokes Dao class

I am taking over a product which is implemented using Struts and plain JDBC framework. I am planning to implement the Junit testing into the project to speed up the testing. FYI, the project is not yet in to production. This is still in Development phase, but is using very old technologies. The project does not have any interface and the respective implementation. Old programming like, the class is directly instantiated and used as such. So, cannot use mockito framework. With all these limitations, I need to develop the TDD into the project. I cannot completely scrap and develop it with new technologies.

My question is: I am writing down a junit test for a business layer to check if that method is working or not. This business class is also making a call to DAO. As the DB connection is not created at the time of test, its giving the connection error. How do I write a junit test to test only the business layer? Should I need to include the DAO connections in test method? If yes, how do I achieve this?

I am a newbie to Junit and the TDD. So, please guide me if my understand is wrong or to fix this.

Aucun commentaire:

Enregistrer un commentaire