测试驱动开发 测试前移_测试驱动的开发可能看起来是工作的两倍-但无论如何您都应该这样做...
测试驱动开发 测试前移
by Navdeep Singh
通过Navdeep Singh
测试驱动的开发可能看起来是工作的两倍-但无论如何您都应该这样做 (Test-driven development might seem like twice the work — but you should do it anyway)
Isn’t Test Driven Development (TDD) twice the work? Should you do it anyway?
测试驱动开发(TDD)是否是工作的两倍? 反正你应该这样做吗?
The short answer to the first question is NO. On the surface, it may seem like without TDD, time is only required to create the feature. With TDD, you need time to create the test AND create the feature, thus doubling the development time required.
对第一个问题的简短回答是“ 否” 。 从表面上看,似乎没有TDD时,创建功能仅需要时间。 使用TDD,您需要时间来创建测试和创建功能,从而使所需的开发时间加倍。
What you’re not considering is the amount of time required for QA testing and debugging when the feature isn’t performing properly.
您不需要考虑的是功能无法正常运行时进行质量检查测试和调试所需的时间。
Case studies were conducted with three development teams at Microsoft and one at IBM that adopted TDD. The results of the case studies indicated that the pre-release defect density of the four products decreased between 40% and 90% relative to similar projects that did not use the TDD practice.
案例研究由Microsoft的三个开发团队和采用TDD的IBM的一个开发团队进行。 案例研究的结果表明,相对于未使用TDD做法的类似项目,四种产品的预发布缺陷密度降低了40%至90%。
Subjectively, the teams experienced a 15–35% increase in initial development time after adopting TDD. (source)
从主观上讲,采用TDD后,团队的初始开发时间增加了15–35%。 ( 来源 )
That 40–90% decrease in pre-release defects means that QA teams and customers weren’t finding and reporting those issues. Engineering wasn’t trying to recreate bugs and develop patches, all of which have associated costs.
预发布缺陷减少40–90%,意味着质量检查团队和客户没有发现并报告这些问题。 工程部门并没有尝试重新创建错误并开发补丁,所有这些都会带来相关的成本。
When discussing TDD, we consider a task to be a subset of a requirement that can be implemented in a few days or less. TDD software engineers develop production code through rapid iterations, as shown in the figure above.
在讨论TDD时,我们认为任务是可以在几天或更短时间内实现的需求的子集。 TDD软件工程师通过快速迭代来开发生产代码,如上图所示。
什么是TDD? (What Is TDD?)
Test-Driven Development is an approach to writing software in which the developer uses specifications to shape the way they implement a feature. For short, we describe it as the “red-green-refactor cycle”.
测试驱动开发是一种编写软件的方法,开发人员使用该规范来规范其实现功能的方式。 简而言之,我们将其描述为“红绿重构周期”。
Before writing any code that adds new functionality to an application, the developer first writes an automated test describing how the new code should behave, and watches it turn red (fail to pass). They then write the code to the specification, and the test turns green (it passes). Finally, the developer takes a little time to make sure that the code just written is as clean as possible (refactoring).
在编写任何向应用程序添加新功能的代码之前,开发人员首先编写一个自动测试,描述新代码的行为,然后观察它变成红色(失败)。 然后,他们将代码写入规范,然后测试变为绿色(通过)。 最后,开发人员需要花费一些时间来确保刚编写的代码尽可能干净(重构)。
为什么您应该关心TDD (Why you should care about TDD)
Automated testing gives your software developers the confidence to make changes to the software and to know that no bugs were created as a byproduct.
自动化测试使您的软件开发人员有信心对软件进行更改,并知道不会产生任何作为副产品的错误。
Additionally, it allows more agility for developers who aren’t familiar with the details of the software to confidently modify the source code without introducing errors.
此外,它为不熟悉软件细节的开发人员提供了更大的灵活性,使他们放心地修改源代码而不会引入错误。
Let’s discuss some really cool advantages of TDD.
让我们讨论一下TDD的一些非常酷的优点。
1. TDD帮助您防止错误 (1. TDD Helps You Prevent Bugs)
First, test suites ensure comprehensive test coverage of the codebase, so bugs are less likely to pop up unnoticed. Second, test suites allow developers to work out potential issues before the application is ready to go into production. Finally, because test suites are constantly maintained, they guarantee software quality.
首先,测试套件可确保对代码库进行全面的测试覆盖,因此,漏洞很少被忽视而不会弹出。 其次,测试套件允许开发人员在应用程序准备投入生产之前解决潜在问题。 最后,由于测试套件不断维护,因此可以保证软件质量。
2.自我解释代码(有据可查) (2. Self Explanatory code (well-documented))
Because refactoring code is a built-in step in TDD, you end up with a much cleaner codebase as you go. Apps built with TDD tend to have less duplication, fewer edge cases that aren’t thought through, and a better overall architecture.
由于重构代码是TDD中的内置步骤,因此最终会获得更加简洁的代码库。 使用TDD构建的应用程序往往具有更少的重复,更少的未被考虑的边缘情况以及更好的整体架构。
The test serves as a specification for what the code that will be written should do. As long as you’re writing good stories, your development team should be able to build exactly what you asked for. If your team agrees to use Acceptance Test-Driven Development, you can even write tests that describe how you want it to work in plain English!
该测试用作将要编写的代码应该做什么的规范。 只要您编写好的故事,您的开发团队就应该能够完全按照您的要求进行构建。 如果您的团队同意使用验收测试驱动开发 ,您甚至可以编写测试来描述您希望它以普通英语工作的方式!
3.避免错误调试器问题 (3. Avoid the bugger debugger problem)
Typically, when talking tech about software development, there are two main types of testing that can be integrated: functional and non-functional. These two types of testing practices are further divided into numerous types of testing techniques as you can see here:
通常,在谈论有关软件开发的技术时,可以集成两种主要的测试类型:功能测试和非功能测试。 您可以在此处看到这两种类型的测试实践进一步分为多种类型的测试技术:
It becomes really important to strategize the testing plan before project commencement, since that helps in clearly defining the roles and responsibilities of developers with respect to testers when it comes to testing.
在项目开始之前制定测试计划的策略非常重要,因为这有助于明确定义开发人员在测试方面相对于测试人员的角色和职责。
For example:
例如:
- Unit and Integration tests to be performed by developers before handing out builds to testers由开发人员执行的单元和集成测试,然后再将构建交付给测试人员
- User acceptance testing to be performed by the testers测试人员要执行的用户接受度测试
- Performance testing and UI testing should be done by both性能测试和UI测试应同时进行
A brief description of a few very important testing methodologies from the diagram above, that should be included in almost every test plan, are covered below.
下面涵盖了上图中一些非常重要的测试方法的简要说明,这些方法应该包含在几乎每个测试计划中。
Unit Testing involves testing individual units of source code to determine if they are fit for use. Intuitively, one can view a unit as the smallest testable part of an application. Faking, Mocking, and Stubbing are indispensable while writing unit tests for code which has API interactions.
单元测试涉及测试源代码的各个单元,以确定它们是否适合使用。 直观地,人们可以将一个单元视为应用程序中最小的可测试部分。 在编写具有API交互作用的代码的单元测试时, 伪造,模拟和存根 是必不可少的。
Integration testing involves a combination of two or more “units” being tested. Integration tests verify that the components of the software all work together or “integrate” appropriately.
集成测试涉及两个或多个要测试的“单元”的组合。 集成测试可以验证软件的各个组件是否可以协同工作或适当地“集成”。
Performance testing is used to ensure that software applications will perform well under their expected workload. The features and functionality supported by a software system are not the only concerns. A software application’s performance, like its response time, reliability, resource usage, and scalability, matters. The goal of performance testing is not to find bugs, but to eliminate performance bottlenecks.
性能测试用于确保软件应用程序在预期的工作负载下能正常运行。 软件系统支持的功能不是唯一的关注点。 软件应用程序的性能(如响应时间,可靠性,资源使用率和可伸缩性 )至关重要。 性能测试的目的不是发现错误,而是消除性能瓶颈。
4.您可以预测麻烦 (4. You can forecast troubles)
The benefit of a comprehensive test suite is that it alerts you to changes early. For example, if your checkout flow stops charging users’ credit cards, you’ll know it right away, because the tests will fail. It also means that if someone makes a mistake and something doesn’t work the way it was supposed to, it will be obvious.
全面的测试套件的好处在于,它可以提醒您及早进行更改。 例如,如果您的结帐流程停止向用户的信用卡收费,您将立即知道,因为测试将失败。 这也意味着,如果有人犯了一个错误,但某些事情却没有按预期的方式工作,这将是显而易见的。
This is good, because it will give you a chance to fix it before it goes to production. If it becomes necessary down the road, you can even start a campaign of deep refactoring without fear, because you’ll have an ironclad test suite that will remain green.
这很好,因为它将为您提供在生产之前对其进行修复的机会。 如果将来有必要,您甚至可以毫无顾虑地发起深度重构运动,因为您将拥有一个铁定的测试套件,它将保持绿色。
5.省钱 (5. Save Money)
When code is complicated, it gets much harder to get anything done — one little change over here can result in a big problem over there. When following TDD, developers can make changes with confidence and your QA team will catch fewer regressions. In development speak, “time saved is equal to money earned.”
当代码很复杂时,完成任何事情都变得更加困难-在这里进行一点更改可能会在那儿导致一个大问题。 在遵循TDD时,开发人员可以放心地进行更改,并且您的质量检查团队可以减少回归。 用发展的话来说, “节省时间等于赚钱。”
6.投资节省的时间进行创新和研究 (6. Invest the saved time in innovations and research)
If we just adopted a TDD approach, much of this money (time saved as expressed in point 5) could be spent on new innovations instead.
如果我们只是采用TDD方法,则其中的大部分钱(如第5点所述,可以节省时间)可以用于新的创新。
7. TDD帮助您避免示波器蠕变 (7. TDD Helps You Avoid Scope Creep)
The nightmare of any project manager is scope creep — any unexpected growth in the scope of work which leads to delays in project delivery.
任何项目经理的噩梦都是范围的蔓延-工作范围的任何意外增长都会导致项目交付的延迟。
Scope creep can happen for various reasons: poorly defined tasks, misinterpretation of project requirements, lack of documentation, and so on. There are many methods aimed at mitigating scope creep, and TDD is one of them.
可能会因各种原因而发生范围爬行:任务定义不正确,对项目要求的误解,缺少文档等。 有许多旨在减轻示波器蠕变的方法,而TDD就是其中一种。
Thanks for reading! Please share it if you found it useful :)
谢谢阅读! 如果您觉得有用,请分享:)
翻译自: https://www.freecodecamp.org/news/isnt-tdd-test-driven-development-twice-the-work-why-should-you-care-4ddcabeb3df9/
测试驱动开发 测试前移
相关文章:

3 OC 属性和方法
1 OC 的属性的生成 interface Student:NSObject {publicint _no;int _age;}property (nonatomic,assign)int height;end 当我们使用property 的时候,那么系统会自动的在其内部生成个属性 xcrun -sdk iphoneos clang -arch arm64 -rewrite-objc main.m -o main.c…

ios绘图时的坐标处理
在iOS中,进行绘图操作时,一般主要是在UIView:drawRect中调用 UIGraphicsBeginImageContextWithOptions等一系列函数,有时候直接画图就行,比如UIImage的drawRect等,有时候需要进行稍微复杂的操作,比如颜色混…

mongoDB数据库操作工具库
/* Mongodb的数据库工具类 */ var client require(mongodb).MongoClient;function MongoUtil() { this.url"mongodb://localhost:27017/storage";//在本地新建数据库storage,此后插入的数据都在storage中 }MongoUtil.prototype.connectfunction(callback…

开源许可证 如何工作_开源许可证的工作方式以及如何将其添加到您的项目中...
开源许可证 如何工作by Radu Raicea由Radu Raicea 开源许可证的工作方式以及如何将其添加到您的项目中 (How open source licenses work and how to add them to your projects) Recently, there was some exciting news for developers around the world. Facebook changed t…

通过API文档查询Math类的方法,打印出近似圆,只要给定不同半径,圆的大小就会随之发生改变...
package question;import java.util.Scanner; import java.lang.Math;public class MathTest {/*** 未搞懂* param args*/public static void main(String[] args) {// TODO Auto-generated method stubSystem.out.println("请输入圆的半径:");Scanner in new Scanne…

4 OC 中的内存分配以及内存对齐
目录 一 OC 中的内存分配 一 OC 中的内存分配 student 结构体明明是20?为什么是24个字节,因为结构体会按照本身成员变量最大的内存进行对齐,最大成员变量是8个字节,因此就是8的倍数,24个字节。 class_getInstanc…

JDE函数--GetUDC(B函数)
GetUDC使用方式: 转载于:https://www.cnblogs.com/GYoungBean/p/4117965.html

k8s crd构建方法_告诉您正在构建没人想要的东西的8种方法(以及处理方法)
k8s crd构建方法by Geoffrey Bourne杰弗里伯恩(Geoffrey Bourne) 告诉您正在构建没人想要的东西的8种方法(以及处理方法) (8 ways to tell you’re building something nobody wants (and what to do about it)) Building something users want is hard — damn hard. They ar…

iOS开发 - 线程与进程的认识与理解
进程: 进程是指在系统中正在运行的一个应用程序,比如同时打开微信和Xcode,系统会分别启动2个进程;每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内;线程: 一个进程要想执行任务,必须得有…

Winform开发中常见界面的DevExpress处理操作
我们在开发Winform程序的时候,需要经常性的对界面的一些控件进行初始化,或者经常简单的封装,以方便我们在界面设计过程中反复使用。本文主要介绍在我的一些项目中经常性的界面处理操作和代码,以便为大家开发的时候提供必要的参考。…

5 OC 中的三种对象
目录 OC 中对象的分类 一 instance 对象 二 类对象 三 元类对象 总结: OC 中对象的分类 instance 对象 类对象 元类对象 一 instance 对象 内存中包含哪些信息 isa 指针 其他成员的变量Student *stu1 [[Student alloc]init]; 以上的stu1 就是实例对象 二 类对象 以…

travis ci_如何使用Travis CI和GitHub进行Web开发工作流程
travis ciby Vijayabharathi Balasubramanian通过Vijayabharathi Balasubramanian 如何使用Travis CI和GitHub进行Web开发工作流程 (How to use Travis CI and GitHub for your web development workflow’s heavy lifting) It’s common to hack together apps on CodePen wh…

android.view.ViewRoot$CalledFromWrongThreadException的解决办法
android 是不允许子线程直接更新UI的,如果一定要在子线程直接更新UI就会出现android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.大概意思就是说 只有原来创建找个视图hierarchy的…

6 OC中 isa 和 superclass 的总结
目录 一 关于isa 和 superclass 的总结 二 为什么基类的metaclass 的superclass 指向的是基类的类 三 isa 的细节问题 总结如下: instance 的isa 指向是classclass 的isa 指向是metaclassmetaclass 的isa指向是基类的imetaclassclass 的superclass 指向的是父类…

opencv下指定文件夹下的图片灰度化(图片的读取与保存)-------简单记录
对于此功能其实很简单:主要是在c方面的字母数字的拼接问题存在一定的问题。C数字字母拼接问题: 1 #include <fstream> 2 #include <string> 3 #include <iostream> 4 #include "highgui.h" 5 #include <cv.h> 6 #…

css菜单缓慢滑动_如何使用HTML,CSS和JavaScript构建滑动菜单栏
css菜单缓慢滑动by Supriya Shashivasan由Supriya Shashivasan 如何使用HTML,CSS和JavaScript构建滑动菜单栏 (How to build a sliding menu bar using HTML, CSS and JavaScript) A menu is what you look for when you land at a website. It has options and gi…

素数环问题---深度搜索遍历
1264: 素数环 时间限制: 1 Sec 内存限制: 128 MB提交: 29 解决: 8[提交][状态][讨论版]题目描述 有一个长度为n的环形序列由1,2,3,...,n组成,环中相邻两个整数和均为素数。你需要找到所有满足条件的环。输入 输入n表示环的长度(n<16)输出…

android之Notification通知
我们在用手机的时候,如果来了短信,而我们没有点击查看的话,是不是在手机的最上边的状态栏里有一个短信的小图标提示啊?你是不是也想实现这种功能呢?今天的Notification就是解决这个问题的。 package cn.com.chenzheng_…

7 OC 中class 类的结构
目录 一 OC 中class 的结构 https://opensource.apple.com/tarballs/objc4/ 在最新的objc源码中 化繁就简来看的话 是以下结构 struct objc_class : objc_object {objc_class(const objc_class&) delete;objc_class(objc_class&&) delete;void operator(con…

apple id无法创建_我们如何使用Apple的学习框架来创建我们的第一个应用程序
apple id无法创建by Jonata Corra由JonataCorra 我们如何使用Apple的学习框架来创建我们的第一个应用程序 (How we used Apple’s learning framework to create our first app) After one month of work, my team and I finished the first version of Echo, our tracker iOS…

个人作业1:小学四则运算——基于控制台
a.需求分析: 自动生成小学四则运算题目的命令行 “软件”,满足以下需求: 除了整数以外,还要支持真分数的四则运算,真分数的运算,例如:1/6 1/8 7/24运算符为 , −, , 并且要求能处理用户…

getchar返回int类型
#include <stdio.h> /* copy input to output; 2nd version */main(){int c;c getchar();while(c ! EOF){putchar(c);c getchar();}} 直觉告诉我getchar返回值应该是char类型的,这个地方为什么不能用char类型来存储getchar()的返回值呢? 其实文中…

8 iOS中KVO 的本质
前言本质 Automatic key-value observing is implemented using a technique called isa-swizzling 这计划的意思就是 自动的键值观察的实现基于 isa-swizzling 原理 1.KVO是基于runtime机制实现的 2.当某个类的属性对象第一次被观察时,系统就会在运行期动态地创…

完成工作表-使用Google Spreadsheets作为数据后端
by Gilad Dayagi通过吉拉德达亚吉 完成工作表-使用Google Spreadsheets作为数据后端 (Get Sheet Done — using Google Spreadsheets as your data backend) If you want to rapidly prototype your next web apps, try using Google Spreadsheets as your data backend.如果您…

BIEE-CSS样式大全
字体属性:(font) 大小 {font-size: x-large;}(特大) xx-small;(极小) 一般中文用不到,只要用数值就可以,单位:PX、PD 样式 {font-style: oblique;}(偏斜体) italic;(斜体) normal;(正常) 行高 {line-height: normal;}(正常) 单位&…

基于verilog的FPGA编程经验总结(XILINX ISE工具)
1.用ISE仿真的时候.所用变量一定要初始化. ISE默认初始量为"XXXXX", 而Quarters是默认为"00000"的, 其实实际上, 下到FPGA里后也是默认为0的,只是可以说ISE严谨得令人DT吧.比如说用一个累加器, result ABresult ,必须保证在某一刻A, B, result都为定值时,…

6 OC 中的isa 指针
目录 一 isa 指针 二 类对象中的superclass 一 isa 指针 isa 指针 ,OC 中的对象都是有的 如下图所示,实例对象isa 指针指向 类对象,类对象的isa 指针指向 元类对象 二 类对象中的superclass superclass 有什么用呢? 比如说创…

btf-raft共识算法_了解Raft共识算法:学术文章摘要
btf-raft共识算法by Shubheksha通过Shubheksha 了解Raft共识算法:学术文章摘要 (Understanding the Raft consensus algorithm: an academic article summary) This post summarizes the Raft consensus algorithm presented in the paper In Search of An Underst…

iOS asset 中定义颜色,xib中便捷访问
在aseet 中定义一个颜色 这样就可以在xib 中访问颜色了,这样就不用重复的去输入

三种序列化方式性能比较
一下代码比较了二进制序列化、xml序列化、Protobuf序列化的运行时间,可是代码显得十分冗余,是否有大神可以指点一二,万分感谢 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; usi…