• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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 ...



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