如何写好一个bug

前言

因为以前我是做测试的,后来在一家公司转开发了,在开发过程中,每次看到测试人员写的bug就很头痛,bug描述不清晰很是影响解决bug的效率,甚至有些bug的描述是有歧义性和个人主观色彩的,后来通过给测试人员设置一些bug编写规范,bug的描述才有了很大的改观。要说明的是,也不能完全就去强调bug的描述,如果团队规模不是很大,测试人员就在跟前,那么可以通过直接沟通,bug的描述也可以适当的简单化,如果公司较大,bug是跨部门存在的,一个好的bug描述就很重要了。

bug描述

组成部分

  • 标题
  • 测试人员个人信息(由谁报的)
  • 测试的设备(需要测试的具体东西是什么)
  • 前提条件(这个bug是在什么环境或者设置下发生的)
  • 重现步骤
  • 期望的结果
  • 实际的结果(如果不好描述可以截图,录视频)
  • 错误恢复(比如测试手机的时候,卡死了,需要说明恢复到正常状态的步骤)
  • 附件信息(可以添加其他一些有助于解决bug的信息)
  • 相关的测试用例(可能其他的一些情况下也出现过这种问题,这有助于开发人员找到问题代码)
  • 其他设备、版本是否有这样的问题(比如测试网站时这个问题在chrome浏览器和360浏览器上出现,IE上不出现)


    既然知道了bug可以添加这么多描述的信息,那么具体如何能够描述的更清晰了

如何描述

标题
标题很重要,一个好的标题,不用看bug描述就能知道所发生的问题:
它应该包括以下三个部分:现象(what),地点(where),条件状态(how)
发生了什么,哪里出现的,如何发生的;要重点描述问题现象,让开发人员能够看到问题的所在。
例如:
当同时插入几张名片到Unified编辑器的时候,”附件添加成功”的提示信息没有显示。

测试人员:一般是由bug管理工具自动生成的,如果bug管理工具是用excel或者word,那么需要填写

测试的设备:越详细越好,对应到具体版本,型号,具体硬件,软件。
下面是一个打印机的描述:设备名字, 固件版本号, 硬件版本号:Madeleine SW 100.48.42 HW B2

前提条件
是发现bug的重要的前提条件,不是每个描述 必须要求的一项,如果没有特殊的条件可以写成:手机在待机状体这样的简短描述
要用陈述句而不是祈使句。尽量用一句完整的句子来描述它

例如:
插入一个内存卡到测试手机中(这个不好)
内存卡已插入到手机中(这个较好)

内容通常包括测试数据,环境(比如网络环境),设置项(比如服务器什么配置),其他(比如手机是否需要重新刷机)

前提条件需要根据具体的测试对象来决定,比如测试手机和网站它们需要不同的考虑

步骤描述
步骤描述是很关键的一环
需要注意以下一些点:句子要简短;每个步骤都要很清晰、表达没有歧义,不少步骤,也没有多余的步骤;争取让每一个人按照你提供的步骤都能重现你的bug
可以强制用起始句来描述,

例如:
1.跳转到测试页面,http://www.baidu.com
2.输入”如何写好一个bug”到搜索输入框
3.点击搜索按钮

步骤描述往往是很容易造成歧义和无法重现bug的地方,应该加以重视

结果描述
期望结果:
按照重现bug的步骤 执行下来后,正确的运行结果应该是怎样的;
期望的结果提供真实的依据,不要将经验值写在期望结果中;
在描述期望结果时要用应该是怎样的句型;

例如:某提示信息”xxxxx”应该显示在页面上。

实际结果:
按照重现bug的步骤 执行下来后,实际的运行结果是怎样就是怎样,不要带有个人色彩。

例如:提示信息”xxxxx”没有显示在页面上。

结果描述中,不要有个人色彩,以免误导开发人员

错误恢复:在实体设备测试时,经常用到,比如 我测试过的打印机,手机经常会出现crash的现象,像一些UI之类的bug就没有必要了。

附件信息:具体情况具体分析,比如一些附件信息

相关测试用例:带上链接地址和标题描述即可

其他设备或者版本信息:在版本迭代中,很有可能因为新增加的代码而触发问题,如果在前后版本对照中一个发生,一个不发生,对定位和解决问题很有帮助,另外不同的设备或者软件有的发生有的不发生,这种兼容性的问题,也很容易就能找到问题原因。

具体例子

这里给出一个以前写过的一个英文版的bug描述,中文版大同小异

Title:”Unknown Error” message pops up when customizing a custom printer email address with dot string in the end.

Preconditions:
Printer: Tsunami 4:1
Serial Number: CN1998ZX1H
Firmware Version: 20110707
Location: USA
Language: English
Connection Type: Wired
Golden Recipe: ICS-SOL1
Date & Time (GMT): 7/20/2011 3:20 PM
Output: NA
ePC config data: http://sips-itg2.austin.hp.com

Steps to reproduce:
1. Power on Cheetah device with 20110711_0018 FW and wait for the printer “Ready”.
2. Make sure the printer has connected to the network.
3. Navigate to Hidden EWS of the Print that is “http:///hp/device/developer/webServices.html” and select ICS-SOL1 Stack and USA region.
4. Enable the “HP Web Services” from EWS and wait for Info Sheet Page printed.
5. Open the ePC < http://sips-itg2.austin.hp.com > using IE9 and claim the printer to ePC with the printer code get from Info Sheet Page.
6. Customize printer email address as one dot string end like “uuuuu.@devtest.cpgtest.ostinet.net”.

Expected Results:
An available message should be appeared for prompt when customizing a custom printer email address which contains dot string in the end of the email address. Please refer to attachment “unknow_error.zip” for details.

Actual Results:
“An error message “Unknown Error” pops up when customizing a custom printer email address which contains dot string in the end of the email address.

Additional information:
1. if more than two underline string or three dot string is contained with email address ,the defect occur also.
2. Two dot string hold together is contained with email address ,the defect occur also.
3. One dot string is contained in the head of email address ,the prompt message is “must be 6-30 characters long”.

  • 4
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是一个简单的 Bug2 算法的伪代码实现: ``` 1. 初始化机器人的位置和目标位置 2. while 机器人没有到达目标位置 do: 3. 如果机器人在自由空间,则直接向目标位置移动 4. 否则,机器人进入障碍物,并绕过障碍物 5. 如果机器人无法绕过障碍物,则返回到上一个位置,并寻找一个新的绕路方案 6. end while 7. 输出机器人已经到达目标位置 ``` 下面是一个使用 Python 语言实现 Bug2 算法的示例代码: ```python import math class Robot: def __init__(self, x, y): self.x = x self.y = y self.heading = 0 def move(self, distance): self.x += distance * math.cos(self.heading) self.y += distance * math.sin(self.heading) def turn(self, angle): self.heading += angle class Bug2: def __init__(self, robot, goal, obstacles): self.robot = robot self.goal = goal self.obstacles = obstacles self.distance_threshold = 0.1 self.heading_threshold = math.pi / 10 self.hit_obstacle = False self.prev_distance = self.distance_to_goal() def distance_to_goal(self): dx = self.goal[0] - self.robot.x dy = self.goal[1] - self.robot.y return math.sqrt(dx*dx + dy*dy) def angle_to_goal(self): dx = self.goal[0] - self.robot.x dy = self.goal[1] - self.robot.y return math.atan2(dy, dx) - self.robot.heading def distance_to_obstacle(self): min_distance = float('inf') for obstacle in self.obstacles: dx = obstacle[0] - self.robot.x dy = obstacle[1] - self.robot.y distance = math.sqrt(dx*dx + dy*dy) - obstacle[2] if distance < min_distance: min_distance = distance return min_distance def can_move_forward(self): distance = self.distance_to_obstacle() return distance > self.distance_threshold def can_reach_goal(self): distance = self.distance_to_goal() return distance <= self.distance_threshold def follow_boundary(self): self.hit_obstacle = True angle = math.pi / 2 while True: self.robot.turn(angle) if self.can_move_forward(): self.robot.move(self.distance_threshold) self.hit_obstacle = False break angle *= -1 if abs(angle) > math.pi: break def update(self): if self.can_reach_goal(): return if self.can_move_forward(): angle = self.angle_to_goal() if abs(angle) > self.heading_threshold: self.robot.turn(angle) self.robot.move(self.distance_threshold) else: if not self.hit_obstacle: self.prev_distance = self.distance_to_goal() self.follow_boundary() if self.distance_to_goal() > self.prev_distance: self.robot.turn(math.pi) self.hit_obstacle = False ``` 在这个示例代码中,我们定义了一个 Robot 类来表示机器人的状态,包括位置和朝向。我们还定义了一个 Bug2 类来实现算法的主要逻辑。在 Bug2 类中,我们实现了一些辅助函数,例如计算机器人到目标位置的距离、计算机器人到最近障碍物的距离等。在主循环中,我们检查机器人当前是否在自由空间,如果是,则直接向目标位置移动;否则,机器人进入障碍物,并绕过障碍物。如果机器人无法绕过障碍物,则返回到上一个位置,并寻找一个新的绕路方案。最后,当机器人到达目标位置时,算法停止运行,输出机器人已经到达目标位置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值