-
Notifications
You must be signed in to change notification settings - Fork 238
Wrong mocked instance returned (StrictExpectations) #450
Copy link
Copy link
Closed
Labels
Description
Passes in 1.28.
Issue #404 was fixed for Expectations only.
StrictExpectations still return wrong instance.
@ContextConfiguration(classes = TestConfig.class)
public class JmockitTest extends AbstractTestNGSpringContextTests {
@Capturing
private SubManager manager;
@Autowired
private System system;
private Entity stub = new Entity();
@Test
public void test() {
new StrictExpectations() {{
manager.find();
result = stub;
}};
final Entity actual = system.call();
assertSame(actual, stub);
}
public static class System {
@Autowired
private SubManager manager;
public Entity call() {
return manager.find();
}
}
public interface SubManager extends Manager {
}
public interface Manager {
Entity find();
}
public static class Entity {
}
@Configuration
public static class TestConfig {
@Bean
protected System system() {
return new System();
}
@Bean
protected SubManager manager() {
return new SubManager() {
@Override
public Entity find() {
throw new UnsupportedOperationException();
}
};
}
}
}
Reactions are currently unavailable