Questions tagged [argumentcaptor]
8 questions
2
votes
2 answers
Mockito test with ArgumentCaptor failing from time to time
I am using Java 17, Spring Boot 2.7.5 (spring-boot-starter-test is introducing JUnit Jupiter and Mockito to my project). Full project code (WIP) is here: https://github.com/Tonypsilon/bmm.backend
I have a method that I want to test:
public void…

Tonypsilon
- 43
- 5
2
votes
0 answers
mockito using in kotlin, how to use ArgumentCaptor> in the test for the function takes Map
having a test using mockito-inline 3.8.0,
it was using java and converted to kotlin then it got compiler error below:
Type mismatch.
Required: (Mutable)Map?
Found: MutableMap<*, *>!
the function to be verified is…

lannyf
- 9,865
- 12
- 70
- 152
1
vote
3 answers
Proper usage of mockito ArgumentCaptor in Java?
I have looked at several usage examples of e.g. Using Mockito ArgumentCaptor, but I have confused about the proper usage for the following scenario:
Here is the method that I want to test:
@Override
public ProductDTO create(Product product, UUID…
user17676679
0
votes
1 answer
Mockito capture Class argument type
How to capture the Class argument of a method with Argument Capture For the following method
public T response(RequestContent requestContent, Class returnType) throws Exception
{
var response = getResponse(requestContent);
var…

Karos
- 51
- 4
0
votes
1 answer
How to use the captor function with jest-mock-extended?
I'm trying to write a test where I'd like to capture the argument of a function. If I understand correctly I'd have to use captor() for this but I can't dig up any examples of how to do so. Simply passing it as an argument to the function I'm…

Adam Arold
- 29,285
- 22
- 112
- 207
0
votes
0 answers
Why are Mockito argument matchers unable to match with my builder-pattern object?
I have a class similar to the following:
package com.example.objects;
import java.util.Objects;
public class MyExampleClass extends SomeBaseClass {
private String param1;
private String param2;
private MyExampleClass(String param1,…

Lord Arryn
- 214
- 2
- 9
0
votes
0 answers
How to use argumentcaptor to capture arguments passed to a constructor?
Say I have an outer class and an inner class set up like this:
public class OuterClass {
public static class InnerClass {
private String data; //no getter exists
public InnerClass(String arg) {
data = arg;
…

manissss
- 101
- 1
- 12
-1
votes
1 answer
Mockito to test change in variables inside void methods
I am trying to test change in arguments supplied to void method using ArgumentCaptor. But I am not able to achieve that . Can somebody please help me find out what exactly I am doing wrong. Using debug I know that list size is…

Loren
- 320
- 1
- 10
- 25