Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JUnit Testing

 
Preeti Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Preeti Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic