使用Powermock测试具有n个参数的方法

时间:2018-08-21 18:00:37

标签: junit powerpoint powermock

所以我正在努力使用超级模拟来调用我的方法。

私有方法

private List<String> addMissingCurrent(Example processor,
            String string1, String string2,
            List<String> listString)
    {

        content....

        return getMissingItems(String1, String);
    }

然后我有一个测试用例,如下所示。

@RunWith(PowerMockRunner.class)
@PrepareForTest(UpdateServiceHandler.class)
public class testClass{

    private static classtotest classtotest;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception
    {       
        classtotest = PowerMockito.spy(new classtotest());
    }

    @Test
    public void addMissingEasyCare() throws Exception
    {
         List<String> returnedValue = null;

         PowerMockito.doReturn(returnedValue).when(classtotest, "addMissingCurrent", anyObject());

    }
}

但是我认为我很挣扎,因为我传递了很多参数。所以我想我的问题是某人如何传递n个参数。另外,您如何检查返回的输出。

0 个答案:

没有答案