jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
458 stars 238 forks source link

MissingInvocation occurs when with(new Delegate,..) api is used in Verifications. #731

Open UchihaYong opened 1 year ago

UchihaYong commented 1 year ago

Hello, The version is jmockit 1.9. When I upgrade the version to 1.36, the problem disappears,. But, I find out some usages of lower version are removed in higher version,so maybe the project will be in trouble. And the problem code as the following,

`public class XXXTest { @Mocked Compute compute;

@Test public void test_X() { new Expectations(){ { compute.testRef((MockClazzOne) any); result=1; } }; new HelloWorldMock().insertOneData(1);

new Verifications() { { compute.testRef(with(new Delegate(){ @Override public boolean equals(Object o) { MockClazzOne clazzOne = (MockClazzOne)o; return clazzOne.getF1() == 1; } })); times=1; } } } }

public class HelloWorldMock { public int insertOneData(int f1) { Compute compute = new Compute(); MockClassOne one = new MockClassOne(); one.setF1(f1); return compute.testRef(one); } } `