软件测试复习题及答案.doc
复习题1.Below is one faulty program. It includes a test case that results in failure. Answer the following questions about the program.(20)(a) Identify the fault.(b) If possible, identify a test case that does not execute the fault.(c) If possible, identify a test case that executes the fault, but does not result in an error state.(d) If possible identify a test case that results in an error, but not a failure. Hint: Don't forget about the program counter.(e) For the given test case, identify the first error state. Be sure to describe the complete state.(f) Fix the fault and verify that the given test now produces the expected output.(a) The for-loop should search high to low:for (int i=x.length-1; i >= 0; i-) (b) All inputs execute the fault - even the null input.(c) If the loop is not executed at all, there is no error. If the loop is executed only once, high-to-low and low-to-high evaluation are the same. Hence there is no error for length 0 or length 1 inputs.Input: x = 3Expected Output: -1Actual Output: -1(d) There is an error anytime the loop is executed more than once, since the values of index i ascend instead of descend.Input: x = 1, 0, 3Expected Output: 1Actual Output: 1(e) The first error state is when index i has the value 0 when it should have a value at the end of the array, namely x.length-1. Hence, the first error state is encountered immediately after the assignment to i in the for-statement if there is more than one value in x.Input: x = 0, 1, 0Expected Output: 2Actual Output: 0First Error State:x = 0, 1, 0i = 0PC = just after i= 0;(f ) See (a)4. Answer questions (a)(d) for the graph defined by the following sets: N = 1, 2, 3, 4,N0 = 1,Nf = 4,E = (1, 2), (2, 3), (3, 2), (2, 4)(a) Draw the graph.(b) List test paths that achieve node coverage, but not edge coverage.(c) List test paths that achieve edge coverage, but not edge Pair coverage.(d) List test paths that achieve edge pair coverage.(a)Omitted.(b) For this program, this is not possible. All test paths must begin at node 1, visit node 2, and, eventually, end at node 4. Any test path that visits node 3 also visits both edge (2; 3) and edge (3; 2).(c) T = 1; 2; 3; 2; 4Note that the edge pair 3; 2; 3 is not toured by the single test path given.(d) T = 1; 2; 4; 1; 2; 3; 2; 3; 2; 45. A graph is defined by the sets of nodes, initial nodes, final nodes, edges, and defs and uses. Each graph also contains a collection of test paths. Answer the following questions about each graph.(a) Draw the graph.(b) List all of the du-paths with respect to x. (Note: Include all du-paths, even those that are subpaths of some other du-path).(c) For each test path, determine which du-paths that test path tours. For this part of the exercise, you should consider both direct touring and sidetrips. Hint: A table is a convenient format for describing this relationship.(d) List a minimal test set that satisfies all defs coverage with respect to x. (Direct tours only.) Use the given test paths.(e) List a minimal test set that satisfies all uses coverage with respect to x. (Direct tours only.) Use the given test paths.(f) List a minimal test set that satisfies all du-paths coverage with respect to x.(Direct tours only.) Use the given test paths.(a)Omitted.6. The graph in Figure 3 was used as an example for prime test paths. Add appropriate edge labels to the graph, then derive and simplify the path expressions. Next add edge weights of 1 for non-cycle edges and 5 for cycle edges. Then compute the maximum number of paths in the graph and the minimum number of paths to reach all edges. This graph has 25 prime paths. Briefly discuss the number of prime paths with the maximum number of paths and consider the effect of varying the cycle weight on the maximum number of paths.(15) Fig 37. Use functions f to answer the following question. 8. How are faults and failures related to testing and debugging?Faults are problems in the code, failures are incorrect external events. Depending on which of Beizer's levels you are working in, testing is the process of trying to cause failures or to show that they occur at an acceptable rate. In contrast, debugging is a diagnostic process where, given a failure, an attempt is made to find the associated fault.错误和失败是如何相关的测试和调试?缺点是代码中的问题,失败是不正确的外部事件。取决于你正在进行的Beizer的等级,测试是一个过程,试图造成失败或表明他们发生在一个可接受的速度。相比之下,调试是一种诊断过程中,给定一个失败,试图找到相关的故障9. For what do testers use automation? What are the limitations of automation?Automation can help in many areas, most often to relieve the tester from repetitive, mechanical tasks. Checking of testing criteria can be automated through instrumentation, which allows a higher level of testing to be performed. Automation will always run into undecidable problems, such as infeasible paths, test case generation, internal variables, etc. Automation cannot help validate output or make creative decisions.自动化的帮助在许多地区,最常来缓解测试人员从重复的,机械的任务。检查测试标准可以自动通过仪器,它允许更高级别的测试被执行。自动化总是会遇到不可判定的问题,如不可行路径,测试用例的生成、内部变量,等等。自动化不能帮助验证输出或使创造性决定的。