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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "junits.." Watch "junits.." New topic
Author

junits..

bhaskar hazarika
Greenhorn

Joined: May 02, 2013
Posts: 11
i need to test a method and my method is calling the service class. As i am new to java can anyone help me how to approach in this issue.
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Hi,

I understand that you have 2 paths to walk you could mock the service, example framework, and test your method or you could initialize your service and test your method.


Best regards,
bhaskar hazarika
Greenhorn

Joined: May 02, 2013
Posts: 11
Thanks Carles..
I have one more concern as my service class is returning the adaptor class do i need to initialize my adaptor class too.??
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
bhaskar hazarika wrote:Thanks Carles..
I have one more concern as my service class is returning the adaptor class do i need to initialize my adaptor class too.??


Depends completely on your code and which path you have choosen mock or initialize
bhaskar hazarika
Greenhorn

Joined: May 02, 2013
Posts: 11
i have initialized my service class as I have limited knowledge on mockobject..
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
What is the scenario a Spring based project?
bhaskar hazarika
Greenhorn

Joined: May 02, 2013
Posts: 11
Yes it is a spring based project.
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Then I assume that when you initialize your Spring context and you get your service from it,
your adaptor is already initialized (in the Spring context) or is initialized by your service class.

Cheers,

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: junits..
 
Similar Threads
Abstract Factory Pattern Vs Factory Pattern
hexFormat in UUID Generation
Who or what is the "caller"?
Garbage collection problem
Zip Directory Recursively