File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JUnit test scope

 
manish ahuja
Ranch Hand
Posts: 312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

We are a bit late into unit testing. We have developed major functionality of the java app (core java).
Now with JUnit testing (forgive my limited knowledge) with most sample examples I have seen is each class is tested in isolation w/out calling other instance/class methods
Now in a real world app that is never gonna be the case and there are inter dependencies between classes. My question in JUnit do we test the complete flow or just test each class's methods in isolation and stub out the dependencies.
Like in my application we have business layer classes which talk to say dao classes which in turn talk to O/R mapping classes. So if go about testing the business layer classes I have to provide input which has to be valid for the dao layer where the database communication is done which is pretty much like testing the whole application flow.

Do post your thoughts.

Thanks
 
Ramesh Kumar
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manish,

If there is no business functionality other than delegating in other classes (Delegates,Facade,....) We can go ahead and write testcases for only controllers and DAOImpl classes.

Yes. If we test the whole functionality they will be integration test cases. For example

If the flow is like this
Controller->Delegate->Facade->DAO->DAOImpl...We write test cases for Controllers. But for running them we need testing frameworks like..JUnitEE, Cactus.......
 
manish ahuja
Ranch Hand
Posts: 312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ramesh.

----------------------

If there is no business functionality other than delegating in other classes (Delegates,Facade,....) We can go ahead and write testcases for only controllers and DAOImpl classes.

-----------------------

Here my question is if we have some business functionality in say delegate layer (just considering for the question in context) but to test the business functionality there are dependencies on the database values (upstream layer) and some input values (downstream layer). How is this scenario taken care in Junit world.

Regards,

Manish
 
Dejan Stojadinovic
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm facing the same problem with JUnit – I can't find running examples and guidelines for integration testing / continuous integration / end-to-end testing / application flow testing (so many terms and keywords...I search on google day and night, but search results are not useful enough...or it is just me looking at wrong places )

So, feel free to share some useful info or at least a key word(s) for better search on google

My stack:

SWING client (I decided to use FEST-SWING http://fest.easytesting.org/swing/wiki/pmwiki.php for SWING testing)
Web services, Hibernate, EJB3 on JBoss app server
MySQL database
JUnit 4
EasyMock (perhaps)
IDE: Eclipse Galileo
Some tool for continuous integration, haven't decided yet (CruiseControl, Cargo-itest, Hudson, TeamCity,...)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dejan,
I think the most important thing is to start small. Maybe some utility methods. Or integration test from the EJB layer. Write a test that checks the API functions as advertised. This covers the back end (EJB, Hibernate and possibly Web Service.) After you get comfortable with that, move on to the Swing GUI.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic