How can I mock an instance of an enum class with PowerMock & Mockito?

前端 未结 3 439
无人及你
无人及你 2021-01-12 07:45

I tried to follow the example offered in the answer to this very similar question, but it does not work for me. I get the following error message:

java.lang.         


        
3条回答
  •  迷失自我
    2021-01-12 08:11

    You need to run this with PowerMockRunner

    eg.

    @RunWith(PowerMockRunner.class)
    @PrepareForTest({ ExampleEnumerable.class})
    @Test(groups = {"LoadableBuilderTestGroup"})
    public class LoadableBuilderTest {
        private ExampleEnumerable mockEnumerable;
    
        @BeforeMethod
        public void setUp() {
            mockEnumerable = mock(ExampleEnumerable.class);
        }
    }
    

提交回复
热议问题