Is it OK to copy & paste unit-tests when the logic is basically the same?

前端 未结 9 2051
悲&欢浪女
悲&欢浪女 2021-02-02 12:09

I currently have like 10 tests that test whenever my Tetris piece doesn\'t move left if there is a piece in the path, or a wall. Now, I will have to test the same behaviour for

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 12:14

    Remember that your tests are pushing against your code. if you find that your tests look duplicated except for something like left/right, then maybe there issome underlying code that left and right is duplicating. So you might want to see if you can refactor your code to use either left or right and send a left or right flag to it.

提交回复
热议问题