What version of OpenRewrite are you using?
- rewrite-testing-frameworks: 3.35.2
- rewrite-core: 8.81.1
- rewrite-java: 8.81.1
What is the smallest, simplest way to reproduce the problem?
import static org.mockito.Mockito.doNothing;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
class ExampleTest {
@Mock Client client;
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
void setUp() {
doNothing().when(client).send(captor.capture());
}
interface Client {
void send(String message);
}
}
Run org.openrewrite.java.testing.mockito.RemoveDoNothingForDefaultMocks.
What did you expect to see?
The stubbing should be preserved because captor.capture() has a side effect. Removing the stubbing changes test behavior.
What did you see instead?
The recipe removes the entire doNothing().when(...) stubbing:
class ExampleTest {
@Mock Client client;
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
void setUp() {
}
interface Client {
void send(String message);
}
}
Any later use of captor.getValue() can fail because no value was captured.
What version of OpenRewrite are you using?
What is the smallest, simplest way to reproduce the problem?
Run
org.openrewrite.java.testing.mockito.RemoveDoNothingForDefaultMocks.What did you expect to see?
The stubbing should be preserved because
captor.capture()has a side effect. Removing the stubbing changes test behavior.What did you see instead?
The recipe removes the entire
doNothing().when(...)stubbing:Any later use of
captor.getValue()can fail because no value was captured.