Verifying sequence of private method calls in unit testing

前端 未结 2 928
暖寄归人
暖寄归人 2021-01-25 09:08

I have the following class:

class MyClass {

  public void doIt() {
     methodOne();
     methodTwo();
     methodThree();
  }

  private void methodOne() {
            


        
2条回答
  •  [愿得一人]
    2021-01-25 09:26

    Hate to be the person but: simply don't test this. Test the output, side effects, results - not the implementation.

    If you really want to ensure the correct order, extract these methods into separate class(es) and mock them.

提交回复
热议问题