0

我无法弄清楚我的测试中的错误在哪里。我PowerMockRunner用来模拟一些静态方法并向JunitParams测试用例添加参数。

当我运行测试时,我收到以下错误:

java.lang.NullPointerException
at org.powermock.modules.junit4.internal.impl.NotificationBuilder.determineTestMethod(NotificationBuilder.java:141)
at org.powermock.modules.junit4.internal.impl.NotificationBuilder.access$000(NotificationBuilder.java:38)
at org.powermock.modules.junit4.internal.impl.NotificationBuilder$OngoingTestRun.<init>(NotificationBuilder.java:86)
at org.powermock.modules.junit4.internal.impl.NotificationBuilder.testStartHasBeenFired(NotificationBuilder.java:233)
at org.powermock.modules.junit4.internal.impl.PowerMockRunNotifier.fireTestStarted(PowerMockRunNotifier.java:112)
at junitparams.internal.ParameterisedTestMethodRunner.runMethodInvoker(ParameterisedTestMethodRunner.java:45)
at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:40)
at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:146)
at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:446)
at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:393)
at org.powermock.modules.junit4.internal.impl.DelegatingPowerMockRunner$2.call(DelegatingPowerMockRunner.java:149)
at org.powermock.modules.junit4.internal.impl.DelegatingPowerMockRunner$2.call(DelegatingPowerMockRunner.java:141)
at org.powermock.modules.junit4.internal.impl.DelegatingPowerMockRunner.withContextClassLoader(DelegatingPowerMockRunner.java:132)
at org.powermock.modules.junit4.internal.impl.DelegatingPowerMockRunner.run(DelegatingPowerMockRunner.java:141)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:117)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
@PowerMockRunnerDelegate(JUnitParamsRunner.class)
@RunWith(PowerMockRunner.class)
@PrepareForTest({ SomeTest.class })
@PowerMockIgnore({ "javax.net.ssl.*", "javax.management.*" })
public class SomeTest {

    private Object[][] requestAndStatusInput() {
        return new Object[][] {
            // some code//
        }
    }
    
    @Test
    @Parameters(method = "requestAndStatusInput")
    public void test_something(String input1, String input2) throws Exception {

        PowerMockito.mockStatic(SomeOtherClass.class);
        PowerMockito.doNothing().when(SomeOtherClass.class, "someMethod", any(), any(), any(), any());

        // some code ///
    }
}
4

0 回答 0