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

verify a Argument Captor in junit tests  RSS feed

Ranch Hand
Posts: 174
  • 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:

  public void testUpdateConceptReferenceDatumIdentifiers() throws SpiderException

    verify(mockInternalJournalToolkitInterface).addIdentifier(basicDataArgumentCaptor.capture(), Matchers.any());
    assertEquals(basicDataArgumentCaptor.getValue().subtype , getBasicData().subtype);
    verify(mockInternalJournalToolkitInterface).getIdentifier(identifierArgumentCaptor.capture(), conceptKeyfArgumentCaptor.capture());

this is my error !!!

Wanted but not invoked:
    <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
  • 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!