我们应该多久编写一次单元测试?

编程入门 行业动态 更新时间:2024-10-19 00:24:26
本文介绍了我们应该多久编写一次单元测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我的导师最近向我介绍了测试驱动的开发方法,他鼓励我在有意义"的时候编写单元测试.我理解为回归测试和折射测试提供完整的单元测试套件的一些好处,但我确实想知道我们应该多久编写一次单元测试以及如何编写单元测试.

I am recently introduced to the test-driven approach to development by my mentor at work, and he encourages me to write an unit-test whenenver "it makes sense." I understand some benefits of having a throughout unit-test suite for both regression testing and refractoring, but I do wonder how often and how throughout we should write unit-test.

我的导师/开发负责人要求我为现有测试类已经在测试的方法中新编写的控制流编写一个新的单元测试用例,我认为这是一种矫枉过正.你多久编写一次单元测试,你认为你的单元测试应该有多详细?谢谢!

My mentor/development lead asks me to write a new unit test-case for a newly written control flow in a method that is already being tested by the exsisting test class, and I think it is an overkill. How often do you write your unit tests, and how detailed do you think your unit tests should be? Thanks!

推荐答案

从技术上讲,如果您遵循严格的测试驱动开发...您应该在对应用程序的任何部分进行规范之后编写单元测试.你应该从:

Technically, if you're following strict Test Driven Development...you should be writing your Unit Tests after you have spec'd any portion of your application. You should be going from:

用户需求 -> 功能设计 -> 单元测试 -> 代码

User Requirements -> Function Design -> Unit Tests -> Code

请记住,在 TDD 中,测试先于代码.

这篇关于我们应该多久编写一次单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 07:42:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405934.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我们应该   单元测试   多久

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!