Skip to content
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

Mocking package-private methods not working in 5.0.0 #331

Closed
b4f-dmueller opened this issue Oct 18, 2022 · 2 comments
Closed

Mocking package-private methods not working in 5.0.0 #331

b4f-dmueller opened this issue Oct 18, 2022 · 2 comments
Assignees
Labels
Milestone

Comments

@b4f-dmueller
Copy link

Hi there,

after upgrading from 4.3 to 5.0.0 mocking a package-private method does not seem to work anymore.
I created a small project that displays the issue: https://github.com/b4f-dmueller/easymock-bug

public class Component {
    String getPackagePrivateValue() {
        return "package-private";
    }

    public String getPublicValue() {
        return "public";
    }
}

While using expect(...) on the public method works as usual, doing the same on the package-private method throws the following exception:

java.lang.IllegalStateException: no last call on a mock available
	at org.easymock.EasyMock.getControlForLastCall(EasyMock.java:479)
	at org.easymock.EasyMock.expect(EasyMock.java:457)
	at org.example.ComponentTest.test_that_package_private_mock_is_working(ComponentTest.java:35)

Am I missing something or is this a bug?
Thanks in advance and thanks for the effort you put in this project!

@henri-tremblay henri-tremblay self-assigned this Oct 18, 2022
@henri-tremblay henri-tremblay added this to the 5.1.0 milestone Oct 18, 2022
@henri-tremblay
Copy link
Contributor

Thanks a lot for the example. I've reproduced it. Let's see what is going on.

@b4f-dmueller
Copy link
Author

@henri-tremblay Thanks a lot for fixing it so fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants