Is there a way to mock construction with mockito-inline only if the constructor arguments match?

1,388 views
Skip to first unread message

Andy Langer

unread,
Apr 28, 2022, 6:42:51 PM4/28/22
to mockito
I'm having issues getting mockito-inline to handle a case that I would encounter when using PowerMock; mocking a construction, but only when certain arguments are in the construction.

For example

```
PowerMockito.whenNew(Car.class).withArguments("Red", "Four Wheels", "Expensive").thenReturn(mockedCar);
```

With mockito-inline, I can mock the construction of a Car by doing

```
try (MockedConstruction<Car> mockedCar = Mockito.mockConstruction(Car.class)){
    Car c = mockedCar.generated().get(0);

    verify(c).someBehavior();

}
```

This does not allow me to only generate a mock when I have specific constructor arguments though. Does anybody know how to do this in mockito-inline?
Reply all
Reply to author
Forward
0 new messages