File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes unit : clarifications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "unit : clarifications" Watch "unit : clarifications" New topic
Author

unit : clarifications

vinay basavanal
Greenhorn

Joined: Dec 08, 2012
Posts: 8
HI All,

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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Pure JUnit is best for non-web code. This would be your service layer/back end. To test the front end, you could use JWebUnit or Selenium.

I recommend starting by just testing your back end with JUnit to get used to testing and build skills before going on to automated testing on the front end.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
vinay basavanal
Greenhorn

Joined: Dec 08, 2012
Posts: 8
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.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unit : clarifications
 
Similar Threads
Reg XA Driver Configuration
Getting ready for the job market quickly - so many technology combinations, how to focus ?
Why is Spring bean lifecycle so elaborate?
Give the easiest example which differentiate "interface" and "abstract class" in Java.
Which Design Pattern and how to design using OOP this scenaria