We want to use junit in our applications, the problem i am facing is , is junit used to test a piece of code or to test functionality.MY appliaction is a web applicaiton .I have get data from ui through servlet/jsf and pass the data to backedn throgh facade pattern i.e i have some service classes and then there is dao layer or a webservice layer which will persist or fetch data from backend services.We have classified our applications in to three projects one is core progject which is like api where we have helper classes like db connection and JDBC utiliity classses.THen there is serice project where basically has service and vo and the web project.NOw how can i use junit in this scenario should i use it to test end to end funcitonality or just do a piece of code testing please help
Thank you now i have mentioned that i have two different projects , one is for service and other is backend layer , service layer interacts with backend what should be my aim actually should it be to test code or functionality, should i write test case for serviced layer alone without backend and how it must be.
author & internet detective
For testing that includes the database, I'd test the service and back end layers together. (Assuming they do what they sound like.) For true unit testing, I'd test them separately and mock out any resources used.
I recommend starting with the testing that involves both layers and the database. It's easier to start with and gives you more bang for the buck.