Software Testing Technique White Box and Black Box
Software Testing Technique White Box and Black Box Testing Technique Md. Al-Imran Lecturer, CSEDIU December 19, 2021 Made By Utpal Ray 1
Software Testing Technique Testing Objective 1. Testing is a process of executing program ( test program ) with an intention of finding errors ( bugs ). 2. A good test case is one that has a high probability of finding an asyet-undiscovered error. 3. A successful test is the one that has uncovered an as-yetundiscovered error. December 19, 2021 Made By Utpal Ray 2
Software Testing Technique Testing Principles 1. All tests should be traceable to customer requirements. 2. Test planning and test preparation should be planned long before testing begins. 3. Test case should be designed keeping the ‘Pareto’ principle in mind which states that, 80% of all the errors uncovered during the testing process are located within the 20% of the program components. 4. Exhaustive testing is never possible because of resource ( manpower, time, money etc. ) constraints. December 19, 2021 Made By Utpal Ray 3
Software Testing Technique Testability – what it is ? How easily a computer program can be tested. How adequately a particular set of tests will cover the product. How easily the product can be checked and repaired in the field. December 19, 2021 Made By Utpal Ray 4
Software Testing Technique Test Case Design � Test case should be designed keeping two test situations in mind. They are : - 1. White Box Testing 2. Black Box Testing December 19, 2021 Made By Utpal Ray 5
Software Testing Technique White Box Testing This method of testing assumes, the tester has a good knowledge about the source code which is under consideration for testing. Depending upon the structure of the source code, the test cases are designed. Each of the test case is supposed to test a unique path through the code. This method of testing is also called Basis Path Testing. December 19, 2021 Made By Utpal Ray 6
Software Testing Technique White Box Testing (contd. ) � Let’s take an example program of which we need to design test cases for white box testing. int find_max ( int a, int b, int c ) { int max; if ( a>b ) then max=a; else max=b; if ( max<c ) then max=c; return max; } December 19, 2021 Made By Utpal Ray 7
Software Testing Technique White Box Testing (contd. ) Flow Chart of the Previous Program 1 2 Declare a, b, c; Define max T a>b Max = a 3 Max=c 6 F 4 5 Max = b T max<c F 7 December 19, 2021 Return max Made By Utpal Ray 8
Software Testing Technique White Box Testing (contd. ) Cyclomatic Complexity Before we proceed to write the test cases we have to know how many test cases will be there at the most. This can be known by a software metric called ‘Cylomatic Complexity’. The Cyclomatic Complexity provides the quantitative measure of the logical complexity of a program. With regard to white box testing, cyclomatic complexity gives us the upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once. December 19, 2021 Made By Utpal Ray 9
Software Testing Technique White Box Testing (contd. ) Cyclomatic Complexity The Cyclomatic Complexity can be computed by adding one to the total number of decision box in the program. As for the program mentioned before, there are 2 decision box shown in the flow chart. So, the cyclomatic complexity is 2+1=3. So, at the most there are three independent path in the program. To find out those independent path, we have to convert the flow chart to flow graph. December 19, 2021 Made By Utpal Ray 10
Software Testing Technique White Box Testing (contd. ) Rules for Flow Chart to Flow Graph Conversion All the process box and the decision diamond should be numbered in the flow chart. A decision diamond should map to a node. A single process box or a sequence of process box should map to a single node. A process box and a decision box can be mapped together to a single node also. The flow should map to a link or edge between the nodes. An edge must terminate to a node, even if the node does not represent any procedural statement. December 19, 2021 Made By Utpal Ray 11
Software Testing Technique White Box Testing (contd. ) 1, 2 4 3 5 6 An independent path is a path, where At least one edge has not been traversed Before. With this rule, we get 3 independent Path. They are : 1. 1, 2 3 5 7 2. 1, 2 4 5 7 3. 1, 2 3 5 6 7 Since, the cyclomatic complexity for this Flow graph is 3; there cannot be more than 3 independent path. 7 Flow Graph December 19, 2021 Made By Utpal Ray 12
Software Testing Technique White Box Testing (contd. ) Test Cases for the previous program Test Case 1 [ for the path 1 ] Input : a>b; a>c Expected Output : a Test Case 2 [ for the path 2 ] Input : b>a; b>c Expected Output : b Test Case 3 [ for the path 3 ] Input : c>a; c>b Expected Output : c December 19, 2021 Made By Utpal Ray 13
Software Testing Technique Black Box Testing It is also known as behavioral testing It focuses on the functional requirement of the software. It is complementary rather then alternative to white box testing. Black Box Testing is performed during the later stages of the software testing; unlike white box testing which is performed during the early stages of software testing. December 19, 2021 Made By Utpal Ray 14
Software Testing Technique Black Box Testing (contd. ) The reason for doing black box testing 1. It uncovers incorrect or missing functions. 2. It detects interface errors. 3. It can detect internal data structure errors or external data base errors. 4. It can point out whether performance of the software is below the desired level. 5. It can spot initialization or termination error. December 19, 2021 Made By Utpal Ray 15
Software Testing Technique � Black Box Testing (contd. ) Test Case Design for Black Box Testing 1. Design test cases in such a way, so that it covers all the functional requirements of the software. 2. Design test cases to test the performance criteria of the software. 3. Design test cases to test the most frequently used inputs given by the user. 4. Design test cases to test the sensitive inputs given by the user. December 19, 2021 Made By Utpal Ray 16
Software Testing Technique �Black Box Testing (contd. ) Test Case Design for Black Box Testing (contd. ) 5. Design test cases to test the boundary condition of the software. 6. Design test cases to test the behavior of the software for reasonable amount of negative inputs. 7. Design test cases to test the maximum load and stress capability of the software. 8. Design test cases to test the security aspects of the software. December 19, 2021 Made By Utpal Ray 17
Software Testing Technique �Loop Testing Technique : 1. Skip the loop entirely. 2. Only one pass through the loop. 3. Two passes through the loop. 4. If n is the maximum no of allowable passes through the loop, then m passes ( m<n ) through the loop. 5. n-1, n, n+1 passes through the loop. Simple Loop December 19, 2021 Made By Utpal Ray 18
Software Testing Technique �Loop Testing ( contd. ) Testing Technique : 1. Start at innermost loop. Set all outer loops to minimum values. 2. Conduct simple loop tests for innermost loop. 3. Work outward, conducting tests for the next loop, but keeping all other outer loops at minimum values and other nested loops to typical values. 4. Continue until all loops have been tested. Nested Loop December 19, 2021 Made By Utpal Ray 19
Software Testing Technique �Home Task A. Design test cases for white box testing for the following set of Programs mentioned below. 1. An array contains n number of integers. Find the maximum number from that array. 2. A program reads 3 integer values. The 3 values represents the 3 sides of a triangle. The program prints a message telling whether the triangle is scalene, isosceles, or equilateral. B. Design test cases for black box testing for the program shown in the beginning of this class. December 19, 2021 Made By Utpal Ray 20
Software Testing Technique December 19, 2021 Made By Utpal Ray 21
- Slides: 21