• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to write test case for if condition

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

Iam very new to junit, iam trying junit at first time so please guide to this will be foundation for me to get concepts about junit.

My code was


This code is having link to private method but simple 2 are 3 steps i want to get idea clear.so help me. I tried some little code in that iam getting error so please help me and guide me.

my junit code


my error is

Please help me

 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jenifer Rajakumar wrote:my error is


That is relatively straightforward - you will find it an easy fix. I'm going to point you to the documentation since it explains it better than I can:

You might want to look at Oracle's Controlling Access to Members of a Class tutorial. Or possibly a better bet (since the first link is a bit terse), the Oracle lesson on Object-Oriented Programming -> Data Access Levels might point you to the easy fix.
 
Kamal Mettananda
Ranch Hand
Posts: 51
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jenifer Rajakumar wrote:My code was my junit code


Just to add to what Andrew he pointed you...

Exception trace has given you a message; Method testGetInitiateSearchEntities should be public , and I believe it is detailed enough.

Also if you look at the getInitiateSearchEntities() and testGetInitiateSearchEntities() methods, first one has public, but not the second one. So always make a practice to read the exception content and see whether you can grab something on how to resolve it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic