• 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

verify a Argument Captor in junit tests  RSS feed

 
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this kind of a method,


I want to capture both datumData.basic and conceptKey here.Both methods called by same mock object.
I verified the method Arguments.But when I tried to capture conceptKey using getIdentifier method it doesn't succeed.
It show it doesn't invoked. But When I debug the code I saw debug is go through getIdentifier() method and I got conceptKey  value also.

Why it doesn't succed;

this is my test case:

@Test
 public void testUpdateConceptReferenceDatumIdentifiers() throws SpiderException
 {

 
   verify(mockInternalJournalToolkitInterface).addIdentifier(basicDataArgumentCaptor.capture(), Matchers.any());
   assertEquals(basicDataArgumentCaptor.getValue().ctx,getBasicData().ctx);
   assertEquals(basicDataArgumentCaptor.getValue().subtype , getBasicData().subtype);
   
   verify(mockInternalJournalToolkitInterface).getIdentifier(identifierArgumentCaptor.capture(), conceptKeyfArgumentCaptor.capture());
   System.out.println(conceptKeyfArgumentCaptor.getValue());  
 }

this is my error !!!

Wanted but not invoked:
mockInternalJournalToolkitInterface.getIdentifier(
   <Capturing argument>,
   <Capturing argument>
);

Is there any way to verify both arguments in one line or any other method to do this?
Please explain me?
 
chamini prashakthi
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh my self found the solution.It was a mistaken from me.
here method call first and then call to
So first I must call to getIdentifier So I added

then verified following lines this order ...



 
Hug your destiny! And hug this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!