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 JUnit test scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit test scope" Watch "JUnit test scope" New topic
Author

JUnit test scope

manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
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

Joined: Dec 28, 2004
Posts: 33
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

Joined: Oct 23, 2003
Posts: 312
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

Joined: Jul 13, 2009
Posts: 5
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30529
    
150

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.


[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit test scope