dongxin1980 2014-11-25 21:26
浏览 17
已采纳

更新原始源代码后,您是否更新了单元测试?

I am so sorry for a noob sounding question. So, I understand unit testing. Of late, I have come across a situation where there is additional methods needed for a class used in a project and redesigning of some methods as well. Do I have to update the unit tests as well?

Philosophically, after you update the code base, are you supposed to keep the same unit test suite or update the unit test suite as well?

  • 写回答

1条回答 默认 最新

  • doumei9589 2014-11-25 21:47
    关注

    Do I have to update the unit tests as well?

    Adding new methods should not require functional changes in existing methods/test.

    Philosophically, after you update the code base, are you supposed to keep the same unit test suite or update the unit test suite as well?

    It all narrows down to whether class contract changes. Contract changes include:

    • you add/remove dependencies
    • you change dependencies contract
    • you make functional change to code (method works differently than previously)

    Any of the above will require change in tests. On the other hand, tests should remain intact when:

    • you refactor your code
    • you extend your class (like adding new methods)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号