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

Partial mocking of global MockUps causes NullPointerException #62

Closed
borisbrodski opened this Issue Sep 12, 2014 · 1 comment

Comments

2 participants
@borisbrodski

borisbrodski commented Sep 12, 2014

Reproduction steps:

Create following files:
  • Tool.java
public class Tool {
    public void doIt() {
    }
}
  • ToolMock.java:
import mockit.Invocation;
import mockit.Mock;
import mockit.MockUp;

public class ToolMock extends MockUp<Tool>{
    @Mock
    public void doIt(Invocation e){
    }
}
  • jmockit.properties:
mocks=test.ToolMock
  • Test1.java:
import mockit.NonStrictExpectations;

import org.junit.Test;

public class Test1 {
    @Test
    public void test1() {
        new NonStrictExpectations(Tool.class) {{
        }};
    }

    @Test
    public void test2() {
        new Tool().doIt();
    }
}
Run Test1.

Result:

  • Test1.test1 OK
  • Test1.test2 FAILS. Exception:
java.lang.NullPointerException
    at test.Tool.doIt(Tool.java)
    at test.Test1.test2(Test1.java:16)

Also all consequent tests getting the same NullPointerException, if Tool class get used.

@rliesenfeld rliesenfeld added the bug label Sep 12, 2014

@rliesenfeld rliesenfeld self-assigned this Sep 12, 2014

@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld Sep 12, 2014

Member

Well spotted, thanks! It will be fixed for release 1.12.

Member

rliesenfeld commented Sep 12, 2014

Well spotted, thanks! It will be fixed for release 1.12.

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