Skip to content

Mocking package-private methods not working in 5.0.0 #331

Closed
@b4f-dmueller

Description

@b4f-dmueller

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!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions