How to use PowerMock with Arquillian?

2019-06-23 19:09发布

问题:

I tried to use PowerMockRule in a JUnit test that uses arquillian but I get java.lang.ExceptionInInitializerError Caused by: java.lang.IllegalStateException: PowerMockRule can only be used with the system classloader but was loaded by ModuleClassLoader for Module

I want to test something like this:

 @RunWith(Arquillian.class)
 @PrepareForTest(WARRRAworkffsTest.class)
 public class WARRRAworkffsTest  {

@Rule  
   public PowerMockRule rule = new PowerMockRule();  


   @Deployment(testable=true)
        public static EnterpriseArchive createDeployment() throws MalformedURLException {

// yadayada

return ear;


}


@Test
public void createTest(){
PowerMock usage
}

}

Can you help me to solve this? Or if you have another idea how should i do it, will be great.