• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JUnit Testing

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 42173
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 42173
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic