Open lewisb42 opened 1 year ago
You should provide arguments for $init after Invocation with the same type of arguments in target constructor. like this
@Mock
public void $init(Invocation inv, int x) {
I would have already done that, except I have a situation where I don't know beforehand what the constructor signatures will be. According to the docs, I should be able to intercept all constructors without specifying their formal parameters. I can already do so with any named method, and in fact for all methods (except constructors) with $advice().
You should provide arguments for $init after Invocation with the same type of arguments in target constructor. like this
@Mock public void $init(Invocation inv, int x) {
Please provide the following information:
Version of JMockit that was used: 1.49
Description of the problem or enhancement request: Per the Mock annotation documentation: "Alternatively, a single fake method having only the Invocation parameter will match all real methods of the same name, regardless of their parameters."
This does not hold true for constructors when faking via
$init
. I.e.,public void $init(Invocation inv)
will only match the zero-parameter constructor, not those having parameters.Check the following:
Sample code:
`// class being faked public class MyClass { private int x;
}`
`// test class class TestInit { @Test void test() {
} `