Testability的论证
原本只是在一本书上看到Testability的介绍,书中对于Testability的介绍使我对Testability中文翻译“可测试性”产生了一些疑惑,从书中的描述中我更倾向于翻译成“易测试性”,而不是可测试性。因此就开始了翻阅Testablity的资料,追溯下来可测试性的翻译确实一点问题也没有,只是书上的描述有点问题。
溯源
Testability在软件工程领域的定义确实有很多,但是究其根源他是一个关于实验假说的一种性质。在逻辑上包含了偶然性、可废止性、可证伪性,也就是说在逻辑上假说是可能存在反例的,并且这个反例是可再现的。
软件工程中的Testability
但是这么一个实验假说的性质在和软件工程相结合后,就出来了各式各样的定义,下面我们就把定义原文记录如下。
- 维基百科:软件可测试性(Software testability)是指一个软件工件(软件系统、模组、需求文件或设计文件等)在一给定的测试环境下,可支援测试的程度。可测试性和设计良好程度的相关性可由以下现象看出:低内聚性、高耦合力、存在多余程式码,以及缺乏封装的程式往往也是不容易测试的程式。若软件的可测试性低,可能会造成测试工作的增加。在一些极端的情形下,缺乏可测试性可能会使部分甚至全部的测试或对软件需求的评估无法进行。为了要找到可测试性以及利用测试找到系统中潜在错误(假设有错误时)的难度的关系,有一种评估可测试性的相对指标,是每一次需要多少的测试用例才能形成完整的测试套件(在测试了所有测试用例后,所得到的结果可以确定此系统符合某规格,或不符合某规格,不会有模糊地带)。若数量不大,表示程式的可测试性高。
- 《Test Techniques for Flight Control Systems of Large Transport Airfcraft》:Testability is a design characteristic that can in a timely and accurate manner determine the state of the system or unit, such as working, nonworking, or performance degradation, and isolate its internal failures. In other words, the unit has the ability of self-diagnosis and failure isolation.
- 《Advances in Computer》:Testability refers to technical characteeristics of the sofeware product that helps testing.
- IEC 60706-5:Testability is a quantitative design characteristic which determines the degree to which an item can be tested under stated conditions.
- 《Engineering Maintanability》:Testability. This is a design characteristic that makes it feasible for the operable, degraded, or inoperable status of an item to be determined and the isolation of faults within the item to be carried out effectively.Three important testability characteristics of modern equipment and systems are:
- Fault-detection capability is the failure rate for those portions of the equipment or system where failures can be detected by the test system divided by the system failure rate.
- Fault-isolation capability:This parameter measures the ambiguity associated with fault-isolation activities.α1 percent of the time, the system is capable of isolating a fault to within γ1 or fewer line replacement units; and α2 percent of the time, the system is capable of isolating a fault to within γ2 or fewer line replacement units. The typical values for α1 α2, γ1, and γ2 are respectively, 0.90, 0.95, 1 or 2 line replacement units, and 2 or 3 line replacement units.
- False-alarm rate:This is the frequency with which the system indicates a failure when there is none。This frequency is the number of false alarms experienced divided by the operational time interval for the system.
可测试性的理解
通过一些文献的查找和学习,我发现Testability并不是起源于软件工程领域,是一个引入的词汇,那么在硬件领域使用更为广泛。在软件工程领域的定义目前看来也有一些不同的定义和解释,对比下来IEC 60706-5标准更为概括和广泛,可测试性是一种定量设计特性,它决定了一个项目在规定条件下可测试的程度(翻译不太好,所以还是推荐看一下上节的原文)。其实是一种可测试的程度,不是容易不容易测试的评价。James Bach定义的可测试性是指一个计算机程序能够被测试的难易程度,重点也是可测试的程度,而不是容易不容易测试。
例如一个Web开发设计中每一个页面的element都没有ID,那么这个其实并不是可测试性的反模式,没有ID同样可自动化测试,只是不容易自动化而已。所以可不可测试的反模式应该是UI设计中需要在固定的嵌入式主机中才能启动测试,没有模拟器,并且测试工程师没有对应的嵌入式主机,从而导致无法测试。
可测试性的一些原则
《Product Development》书中给出了一些Testability的原则:
- Design product components such that tests can be done with standard equipment.
- Incorporate built-in test capability and, if possible, built-in self-testing devices in the product.
- Make the tests easy and standardized, capable of being performed in the field.
- Provide accessibility for test probes; for instance, make test points more prominent and provide access parts and tool holes.
- Make modules testable while still assembled in the product (Anderson, 1991).