*
The moose likes Testing and the fly likes JUnit Testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit Testing" Watch "JUnit Testing" New topic
Author

JUnit Testing

Preeti Prabhakar
Greenhorn

Joined: Jul 27, 2009
Posts: 12
Hi All,

I am new to JUnit test cases. We are starting to write JUnit test cases to perform automated testing for a web application which is running on production. Ours is a layered application.

1. Should we write test cases for all public methods or do we write only for business methods in the business layer ?
2. How should positive and negative test cases be covered ? Do we write test cases for all scenarios?
3. Since ours is a web application, is it better to use HttpUnit than JUnit ?

Waiting for your response

Thanks
Preeti
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30596
    
154

Preeti,
1) You should eventually have test cases for all methods. This is overwhelming at first so start with what makes sense. This may be the business layer.
2) Yes all scenarios including negative tests should be covered. What are logical paths in the code you are trying to test.
3) HttpUnit is for testing through the web. JUnit is for testing at a lower level. It is good to have both since they test different things. I recommend testing as much as possible with pure JUnit so you get the logic tested this way. Then the HttpUnit tests only have to test the true web interaction and not the business logic.


[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
Preeti Prabhakar
Greenhorn

Joined: Jul 27, 2009
Posts: 12
Thanks Jeanne for the quick response.

I agree that test case has to be written for all public methods. But i still have my apprehensions as we are working with a long running application that has code running into around half a million lines. What would be the best approach to write test cases in this scenario ? Is it like both positive and negative test cases for all public methods ?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30596
    
154

Preeti Prabhakar wrote:Thanks Jeanne for the quick response.

I agree that test case has to be written for all public methods. But i still have my apprehensions as we are working with a long running application that has code running into around half a million lines. What would be the best approach to write test cases in this scenario ? Is it like both positive and negative test cases for all public methods ?

It's to start. A bit application is overwhelming if you look at the whole thing. Can you start with a smaller part of the application?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JUnit Testing