# ArgumentCaptor

You can also get value of parameters of mocked methods, you can then Assert for their value.

Below is the same example of calculator class.

```java
// example statement
final int addition = calculator.getAddition(2, 3);

// Create captor
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);

Mockito.when(mckCalculator.getAddition(argumentCaptor.capture(), argumentCaptor.capture())).thenReturn(5);

final int firstNum = argumentCaptor.getValue();
Assert.assertEquals(2, firstNum);

// You can get second num by calling getAllValues()
final int secondNum = argumentCaptor.getAllValues()[1];
Assert.assertEquals(3, secondNum);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.tejpratapsingh.com/_/java-testing/mockito/argumentcaptor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
