Testing levels

  • Unit testing 单元测试
    测试某一小部分代码的正确性,尤其是测试某个函数。
  • Integration testing 集成测试
    The combined execution of 2 or more classes, packages, components, subsystems that have been created by multiple programmers or programming teams.
  • System testing 系统测试
    测试一整个已经集成好的系统,看这个系统是否满足需求,即在最终的一个配置下运行软件。

Test vs Debug

Testing是为了发现是否存在错误
Debugging为了识别、定位已知错误的根源

White-box vs black-box testing

白盒测试是对程序内部代码进行的测试。
黑盒测试仅针对陈旭外部表现出的行为进行测试。
软件测试的困难所在:穷举、暴力测试是不现实的。

Test case

测试用例=输入+执行条件+期望结果
好的测试用例需要有一下属性:
Most likely to catch the wrong
Not repetitive and not redundant
The most effective in a group of similar test cases
Neither too simple nor too complicated

Test-First programming

测试优先的编程:在写程序代码之前先写测试用例。
不要把测试留到最后。
测试用例要根据方法的规约(specification)来写,同时,写测试用例也是理解、修正、完善规约的过程。
(规约本身也有可能是错误的——不正确、不完整。)
测试优先可以尽早的发现规约中的问题,避免浪费时间去做错误的事情。
越早发现错误就越容易去纠正错误。

Unit Testing

Unit testing focuses verification effort on the smallest unit of software design —— the software component or module.
单元测试需要考虑的东西:
接口,测试的输入和输出;数据的完整性;所有语句都要被执行到过;所有的边界都要测试到。
Test cases for the black-box testing are built around specification and requirements. 测试用例的编写必须符合规约。

Choosing Test Case by Partitioning

按照等价类划分设计测试用例
Equivalence partitioning is a testing method that divides the input domain of a program into classes of data from which test cases can be derived.
针对每个输入数据需要满足的约束条件,划分等价类。
此方法可以将有限的测试资源最大化利用。

Guidelines

如果限定了输入数据的范围,则按不同范围划分;
如果指明了特定的值,则将几个特定的值按内在联系划分;
如果输入数据是Y/N,将两个都测一遍。

Example1

BigInteger.multiply():
BigInteger × BigInteger -> BigInteger
input: (a, b),从正负的角度对二维空间进行等价类划分:
a and b are both positive
a and b are both negative
a is positive, and b is negative
a is negative, and b is positive

需要考虑的特殊情况:0
考虑输入的上限:面对很大的数是否仍然正确?
综合以上的所有,划分为49个等价类:

从每个正方形内任意选取一组(a, b)

Example 2

public static int max(int a, int b)
int × int -> int
按如下等价类:
a < b
a = b
a > b

Boundary Value Analysis

A greater number of errors occurs at the boundaries of the input domain rather than in the center.
0 is a boundary between positive numbers and negative numbers.
Maximum and minimum values of numeric types, like int and double.
Emptiness (the empty string, empty list, empty array) for collection types.
The first and last element of a collection.

边界值分析方法是对等价类划分方法的补充。

重新设计max()的规约:
Relationship between a and b:
a < b
a = b
a > b

Value of a:(so is b)
a = 0
a < 0
a > 0
a = minimum integer
a = maximum integer

White-box testing

Whitebox testing (also called glass box testing) means choosing test cases with knowledge of how the function is actually implemented.

For example, if the implementation selects different algorithms depending on the input, then you should partition according to those domains.
If the implementation keeps an internal cache that remembers the answers to previous inputs, then you should test repeated inputs.

Other things

Running all your tests after every change is called regression testing.
Unit testing strategy is a complementary document of ADT’s design.
Aligning with the idea of test-first programming, it is recommended to write down the testing strategy (such as partitioning and boundary) according to which you design your test cases.

Testing and Test-First Programming相关推荐

  1. 软件构造的视图与质量指标

    软件构造的实质:Transformation between different views(不同视图之间的转换) Multi-dimensional software views 按阶段分:buil ...

  2. 如何选择python书籍_如何选择一本优质的数据科学书籍

    怎样 选书 选择一本合适 的数据科学书至关重要,一本不适合 的书会糜费 你的时间以及肉体 . 有时分 ,书的大纲可能正合你意.但是随着你深化 阅读时,可能会发现作者只触及了表面 ,并不够深化 .这种状 ...

  3. 软件构造 第一章第二节 软件开发的质量属性

    ​软件构造 第一章第二节 软件开发的质量属性 1.软件系统质量指标 External quality factors affect users 外部质量因素影响用户 Internal quality ...

  4. 基于python渗透测试_Python中基于属性的测试简介

    基于python渗透测试 by Shashi Kumar Raja 由Shashi Kumar Raja Python中基于属性的测试简介 (Intro to property-based testi ...

  5. Linux Journal 2013点评 Readers' Choice Awards 2013

    Readers' Choice Awards 2013 资料来源于:http://www.linuxjournal.com/rc2013 加以整理 Best Linux Distribution   ...

  6. 计算机与软件工程-研究生复试-专业面试-零碎基础知识-2

    Java和C 在构造器和编译器在多继承方面区别 你觉得数据结构的算法和机器学习的算法有什么区别 数据结构让我掌握如何与机器交互,用计算机的视角去思考问题,机器学习教会计算机如何理解人类世界的问题,用人 ...

  7. p值 统计学意义_什么是统计意义? P值定义以及如何计算

    p值 统计学意义 P values are one of the most widely used concepts in statistical analysis. They are used by ...

  8. python自动化介绍

    自动化测试===自动化测试分类(一) 分层的自动化测试 测试金字塔的概念由敏捷大师Mike Cohn 在他的<Succeeding with Agile>一书中首次提出,如图7.1所示.他 ...

  9. 程序员一生必读的书籍

    程序员一生必读的书籍 软件业的特点是变化.若要提高软件开发的技能,就必须跟上技术发展的步伐.埋首醉心于项目开发与实战,固然能够锤炼自己的开发技巧,却难免受限于经验与学识.世界上并不存在速成的终南捷径, ...

  10. Software Processes

    Software Processes Slide 2 Objectives  To introduce software process models  To describe three gen ...

最新文章

  1. Linux 指令篇:文件系统--fstab
  2. 精确到秒的JQuery日期控件,jquery日历插件,jquery日期插件
  3. poj 1106 Transmitters (枚举+叉积运用)
  4. 动态规划之——拦截导弹(nyoj79)
  5. 每天一道LeetCode-----将数字集转成字母集,计算有多少种转换方式
  6. 新加入“扫码阅读”功能
  7. 如何加入github开源项目!
  8. [置顶] Android之Handler用法总结
  9. redis php高级使用_项目中应用Redis+Php的场景
  10. pe备份linux系统教程,将CDlinux整合在U盘PE启动界面
  11. 854计算机专业基础,2020年哈工大考研《854计算机基础》考试大纲
  12. Linux系统基于MobaXterm的下载及使用
  13. AT32看门狗WDT使用方法
  14. 智能管家项目总结(2)
  15. 【基础】【前端】 HTML Select 框怎么做预选值
  16. 北京交通大学c语言作业,北京交通大学c语言综合程序设计(黄宇班).doc
  17. 千杯酒中检测那一杯毒酒的问题及思考
  18. 教师招聘计算机面试说课稿,教师招聘面试常见问题_ _信息技术说课稿.doc
  19. Java的API(Scanner\Object\Date区\Math\Random\Arrays\String区\regex\包装类...)一般是parse(String)
  20. 什么?!NEON还要优化?

热门文章

  1. 数据中心节能环保政策汇总分析:2022年新建大型数据中心PUE需达到1.4以下
  2. 数据中心机房工程建设需要注意的重大问题
  3. 你以为没有CAD的前辈们画不出复杂的图纸?
  4. 机房突然发生爆炸事件如何处理?为什么会这样
  5. latex参考文献顺序不对_latex模板中,引用多篇参考文献,连续引用压缩问题
  6. 如何查看dll被那个service占用_不小心执行 rm -f,该如何恢复?
  7. ML:MLOps系列讲解之《MLOps的定义与发展—你为什么可能想使用机器学习》解读
  8. 成功解决Windows10环境下运行Linux系统下的.sh文件
  9. Py之folium:python库之folium的简介、安装、使用方法之详细攻略
  10. 微信小程序图片轮转播放