So I'm trying to get rid of PowerMock as I'm updating to java 17 by using EasyMock.
But I hit a wall trying to convert this :
PowerMock.expectNew(File.class, "path").andReturn(fileMock).times(1);
Into the Easymock alternative.
I wrote smth like this.
EasyMock.expect(new File("path")).andReturn(fileMock).times(1);
But it doesn't seem to work, and I keep hitting
java.lang.IllegalStateException: no last call on a mock available.
Any ideas would be welcome. Thanks
You can't mock
newwith EasyMock. It's not supported. But I will argue that you do not need to mock File. You can just create and actual file.If needed, extract to a method the piece of code creating the
File, create a partial mock and make that method returning aFilethat suits your purpose.