Further with powermock and Parameterized tests
Par Quentin Ambard le mardi, février 15 2011, 14:49 - Lien permanent
here are a couple of tips if you need when you implement a Junit Parameterized test with powermock:</p>
- Use the @RunWith(Parameterized.class) annotation for your class</p>
- Use the @PrepareForTest() annotation at the class level, not the method !
- Add a Junit PowerMockRule : @Rule public PowerMockRule rule = new PowerMockRule();
- If you get error with class loader,
... Caused by: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. ... Or an exception with java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl etc...
try to ignore the class where you get the error (or the one which is invoking SAXParserFactoryImpl, for instance): @PowerMockIgnore({"myapp.utils.addresses.*", "org.apache.commons.logging.*"}) etc.