my dog learned polymorphism*
The moose likes Testing and the fly likes How to write test case for if condition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to write test case for if condition" Watch "How to write test case for if condition" New topic
Author

How to write test case for if condition

Jenifer Rajakumar
Ranch Hand

Joined: Oct 31, 2013
Posts: 34
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

Joined: Mar 28, 2003
Posts: 11404
    
  81

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.

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Kamal Mettananda
Ranch Hand

Joined: Oct 25, 2005
Posts: 51

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.


Kamal Mettananda - SCJP 1.4 (98%)
 
Don't get me started about those stupid light bulbs.
 
subject: How to write test case for if condition
 
Similar Threads
NoClassDefFoundError exception in InitialContext()
Problem creating mock using PowerMock
java.lang.IllegalStateException: Failed to transform class- when using @PrepareForTest in Intellij
How to write a JUnit test for List?
Error In creating bean with name sessionFactory