Why are functional tests not enough? What do unit tests offer?

前端 未结 8 1160
庸人自扰
庸人自扰 2020-12-25 09:02

I just had a conversation with my lead developer who disagreed that unit tests are all that necessary or important. In his view, functional tests with a high enough code cov

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 09:54

    In TDD/BDD, unit tests are necessary to write the program. The process goes

    failing test -> code -> passing test -> refactor -> repeat

    The article linked also mentions the benefits of TDD/BDD. In summary:

    • Comes very close to eliminating the use of a debugger (I only use it in tests now and very rarely for those)
    • Code can't stay messy for longer than a few minutes
    • Documentation examples for an API built-in
    • Forces loose coupling

    The link also has a (silly) walk-through example of TDD/BDD, but it's in PowerPoint (ew), so here's an html version.

提交回复
热议问题