wood burning stoves*
The moose likes Testing and the fly likes How to write a JUnit test for List? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to write a JUnit test for List?" Watch "How to write a JUnit test for List?" New topic
Author

How to write a JUnit test for List?

Jenifer Rajakumar
Ranch Hand

Joined: Oct 31, 2013
Posts: 33
Hi

Iam new to Junit, i have completed my 50% junit test code but now iam getting some complex once, no one is not there to guide me, so please solve my issues and help me.

My code is

For this i have tried and return the Junit code Bit


But iam getting error



I have used below code also



Please Help me to solve my issues. Thanks in advance.
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 761
    
    9
It looks like you just have a normal Java typing problem on line 7 where you are trying to cast initiateSearchEntities (a List) to a SearchCriteria object.

Did you mean to write just initiateSearchEntities instead of ?
Jenifer Rajakumar
Ranch Hand

Joined: Oct 31, 2013
Posts: 33
Hi

Now i retify the issues but now iam getting one more, my method is going to private method. So please guide me to solve me and tell me where iam giving wrong code.and what i want to do.


Java Code




Now i have did juit code till to call private method

junit code




My exception is



Where i don't know please guide me.
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

I think this is caused by the unmatch of MemRowList.
The actual call of getInitiateSearchCriteria passed new MemRowList() as parameter but you are expecting another instance of MemRowList
May be you need EasyMock.anyObject(MemRowList.class) ?
Jenifer Rajakumar
Ranch Hand

Joined: Oct 31, 2013
Posts: 33

IAM VERY NEW, so in place i need to change, please can you show me
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2


should be replaced by
Jenifer Rajakumar
Ranch Hand

Joined: Oct 31, 2013
Posts: 33
hi
Now iam getting this error


Jenifer Rajakumar
Ranch Hand

Joined: Oct 31, 2013
Posts: 33
Please Guide me Depends on this only my performance is there. iam trying a lot but iam new so please what i need to improve and what i need to read please help me.

Iam posting my full code



My Junit code


Please guide me where i am doing mistake. plese

Now iam getting error
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

Perhaps you need to wrap your parameter with eq

I think reading EasyMock tutorial and API may help
Jenifer Rajakumar
Ranch Hand

Joined: Oct 31, 2013
Posts: 33
Now iam getting

Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

You have to learn to diagnose the error message and fix it by yourself.
It tells you a method called is unexpected.

Think about what object it is and how it is used and doing something for this object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to write a JUnit test for List?
 
Similar Threads
Hibernate DAO MAVEn testing unit
JNDI Lookup & Caching issue on multiple BEA instances
Powermock - Creating mock object for final class and mock it for a static method
Help needed for setting JMock
Problem creating mock using PowerMock