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

前端 未结 9 2141
悲&欢浪女
悲&欢浪女 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:34

    I agreed @Rob. The code needs refactoring. But if you don't want to do refactor the code at this point of time then you can go and have parametrized tests. The same test run for different parameters. See TestCase and TestCaseSource attributes in nunit.

    Refer http://nunit.org/index.php?p=parameterizedTests&r=2.5

提交回复
热议问题