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?
You can put Spy instead the Mock if arguments don't match. There's a method that allow to configure mock creating settings:
So, will be something like that: