Skip to content

@Mock fields are not injected anymore (1.6.5 regression) #668

@andrei-ivanov

Description

@andrei-ivanov

Hi,
After upgrading from 1.6.4 to 1.6.5, a lot of tests are failing.
Quick investigation shows that @mock marked fields don't get injected anymore.

import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.powermock.api.easymock.PowerMock.replayAll;
import static org.powermock.api.easymock.PowerMock.verifyAll;
import static org.powermock.reflect.Whitebox.setInternalState;

import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.annotation.Mock;
import org.powermock.api.extension.listener.AnnotationEnabler;
import org.powermock.core.classloader.annotations.PowerMockListener;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PowerMockListener(AnnotationEnabler.class)
public class IncidentFacadeImplTest {

    @Mock
    private IncidentPropertyChangeDAO incidentPropertyChangeDAO;
}

I assume this has something to do with the processing of the AnnotationEnabler, but as this is a minor update, it shouldn't break.

Using this with EasyMock 3.4 and JUnit 4.12

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions