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

Capturing with StrictExpectations wrong mocking #445

Closed
Milbor opened this Issue Aug 15, 2017 · 0 comments

Comments

2 participants
@Milbor

Milbor commented Aug 15, 2017

1.33 fail
1.28 pass


import org.testng.annotations.Test;

import mockit.Capturing;
import mockit.StrictExpectations;

import static org.testng.Assert.assertEquals;

public class JmockitTest {
    @Capturing
    private Manager manager;

    @Test
    public void test() throws Exception {
        final String expected = "expected";
        new StrictExpectations() {{//passes with Expectations
            manager.find(String.class);
            result = expected;
        }};
        final String actual = getManager().find(String.class);
        assertEquals(actual, expected);//is null
    }

    private Manager getManager() {
        return new Manager() {
            @Override
            public <T> T find(final Class<T> clazz) {
                throw new UnsupportedOperationException();
            }
        };
    }

    public interface SuperManager {
        <T> T find(Class<T> clazz);
    }

    public /*passes with package visibility*/ interface Manager extends SuperManager {
    }
}

@rliesenfeld rliesenfeld self-assigned this Aug 15, 2017

@rliesenfeld rliesenfeld added the bug label Aug 15, 2017

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

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