How can I load a json file from an android unit test that is run with PowerMockRunner? How can I load a json file from an android unit test that is run with PowerMockRunner? json json

How can I load a json file from an android unit test that is run with PowerMockRunner?


You have two options:

  • try to get system classloader via ClassLoader.getSystemClassLoader()
  • Get classloader from the class that has been ignored by PowerMock. By default:

"org.hamcrest.", "java.", "javax.accessibility.", "sun.", "org.junit.", "org.testng.", "junit.", "org.pitest.", "org.powermock.modules.junit4.common.internal.", "org.powermock.modules.junit3.internal.PowerMockJUnit3RunnerDelegate", "org.powermock.core*", "org.jacoco.agent.rt.*"

Or you may use @PowerMockIgnore.