Mockito - returning the same object as passed into method

后端 未结 3 902
-上瘾入骨i
-上瘾入骨i 2021-02-11 12:36

Let\'s imagine I have a following method in some service class:

public SomeEntity makeSthWithEntity(someArgs){
    SomeEntity entity = new SomeEntity();
    /**
         


        
3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-11 13:25

    Or better using mockito shipped answers

    when(mock.something()).then(AdditionalAnswers.returnsFirstArg())
    

    Where AdditionalAnswers.returnsFirstArg() could be statically imported.

提交回复
热议问题