• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How to write Junit for only for get method

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi


Iam new to Junit, I have return some some but it was getting error. because now iam facing concept with return type. please guide me.




Junit Code



But iam getting error



Please solve my exception.
 
Sheriff
Posts: 4633
300
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately without giving us the complete picture it's hard to say what the problem is. On the face of it a NPE could occur in your test method because you may not have initialised rolloverServiceImpl, or pcpId might be null and the method you're testing throws the NPE. But then I see in the stacktrace that you're using PowerMock. Why? Nothing in the test code you've presented requires it.

In order to make things a little clearer you need to do one of two things:
1) If mocks are being used for this test then show us where and how?
2) If mocks are not being used for this test then don't use the PowerMock runner and run the test with just jUnit.

Let us know how you get on.
 
Jenifer Rajakumar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks For Your Reply Tim. Now i got the result, I am sharing my code for others reference.


1. First we need to set method for hmoRolloverDAO because in retuning values.
2. use EasyMock for return statement and use andReturn(rolloverPCP) because method is public RolloverPCP getSenderByPCPId(String pcpId) {}
3. PowerMock.replay for mockup values.




 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!