Create a mocked list by mockito

后端 未结 3 687
花落未央
花落未央 2021-02-01 15:19

I want to create a mocked list to test below code:

 for (String history : list) {
        //code here
    }

Here is my implementation:

3条回答
  •  独厮守ぢ
    2021-02-01 15:51

    When dealing with mocking lists and iterating them, I always use something like:

    @Spy
    private List parts = new ArrayList<>();
    
        

    提交回复
    热议问题