Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

junits..

 
bhaskar hazarika
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have initialized my service class as I have limited knowledge on mockobject..
 
Carles Gasques
Ranch Hand
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the scenario a Spring based project?
 
bhaskar hazarika
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is a spring based project.
 
Carles Gasques
Ranch Hand
Posts: 199
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic