编程:关于testing和debugging

来源:互联网 发布:阿里云备份 编辑:程序博客网 时间:2024/05/20 13:08

2014.4.11

参考材料:Data Structures, Algorithms, and Applications in C++: Sartaj Sahni

1.5 Testing and Debugging

(1~4:what is testing)(5:Designing Test Data)

1: "Verifying agreement between observed and expected behabior on a proper subset of the possible inputs does not prove that the program works correctly on all inputs."

意思是说,你不太可能将所有可能的输入都进行测试,如一个输入需要int类型数据,则你要测试2^32个输入(大概有4*10^9)。因此我们往往是从所有可能的输入中选取一个test subset。所以就算这个test subset中所有输入测试都正确,你也不能确定这个程序在整个输入集上都正确。


2" As a result of the above idea, "the objective of tesing is not to establish correctness, but to expose the presence of errors.", and "different test sets can expose different errors in a program."

意思是说,按照上面那个观点进一步说。既然测试一个subset不能确保这个程序对所有输入都正确,那么测试一个test subset的主要意义就不是证明这个程序完全正确。测试一个subset的主要意义是要expose程序中的error。


3: "if the test data did not execute all statements of the code, we have less confidence in the correctness of the stetements that are no executed."


4; "test set that executes all statements of program has a better chance of exposing the errors in the code."

item3和4的意思是说,如果测试的数据能让程序的每个部分都运行过,那么我们就更有信心说这个程序没有问题。(因为如果test subset让程序的某一部分没有运行过,那我们就not confident about那个没有运行的部分是不是没有问题)


5; "Techniques for test data development fall into two categories: balck box methods & white box methods."

"In a black box method, we consider the program's function, not the actual code, when we develop test data."

"In a white box method, we examine the code in a an attempt to develop test data whose execution results in a good coverage of the program's stetements and execution paths."

测试数据的设计技术按照需不需要观察程序代码分为:黑盒技术和白盒技术

用黑盒技术设计来测试集,是根据程序的功能来设计,不看代码;

白盒技术设计,则是观察代码,设计出一个test subset使得程序的每个部分都充分运行,提高我们的confidence


6: "Testing exposes the presence of error in a program"

"Debugging is the precess of determining and correcting the cause of the discrepency between the desired and observed behaviors"

就是说,Testing是告诉你程序中存在问题呀!而你Debug来确定问题的原因,并且改正


7: some suggestions for debugging(first & last seems good; second not understood, though)

0 0
原创粉丝点击