dimanche 28 juin 2015

Mockito to test second layer classes

I am working on a angularJS + spring Restful API testing. I want to use front (web) testing to do positive test. Ensure data is stored in the database and query out. etc I am thinking to use unit test (testNG) to replace the API testing now. I know there are some other options, but this is what I am looking now. Looking forward for some discussion or some mature method of this.

Here is software structure webUI <-> SpringMVC controller <--> Object manager <--> DAO. like post method of api/v1/order URL match to controller.addOrder method. It calls manager.addOrder method and manager.addOrder call order.DAO method.

Currently we use mockito. When write unit test for controller.addOrder, we mock the manager.addOrder method. When write unit test for manager.addOrder, we mock the DAO. This makes me not quite confident about it because it does miss something. So Is there a method to testcontroller.addOrder but only mock DAO. Let the real call come through controller->manager. That gives me more confidence.

Aucun commentaire:

Enregistrer un commentaire