New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong mocked instance returned (StrictExpectations) #450

Milbor opened this Issue Aug 28, 2017 · 0 comments


2 participants

Milbor commented Aug 28, 2017

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 {
    private SubManager manager;
    private System system;
    private Entity stub = new Entity();

    public void test() {
        new StrictExpectations() {{
            result = stub;
        final Entity actual =;
        assertSame(actual, stub);

    public static class System {
        private SubManager manager;

        public Entity call() {
            return manager.find();

    public interface SubManager extends Manager {

    public interface Manager {
        Entity find();

    public static class Entity {

    public static class TestConfig {
        protected System system() {
            return new System();

        protected SubManager manager() {
            return new SubManager() {
                public Entity find() {
                    throw new UnsupportedOperationException();

@rliesenfeld rliesenfeld self-assigned this Aug 29, 2017

@rliesenfeld rliesenfeld added the bug label Aug 29, 2017

@jmockit jmockit locked and limited conversation to collaborators Oct 29, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.