Software Testing Techniques Lecture PDF
Document Details
Uploaded by ImportantFlerovium
ICFAI University
Tags
Summary
This lecture covers different software testing techniques. It explains concepts like white-box and black-box testing, basis path testing, and flow graph notation. Software testing is a crucial part of software engineering.
Full Transcript
Software Testing Techniques - White-box testing - Black-box testing Two Unit Testing Techniques Black-box testing – Knowing the specified function that a product has been designed to perform, test to see if that function is fully operational and error-free – Includes tests t...
Software Testing Techniques - White-box testing - Black-box testing Two Unit Testing Techniques Black-box testing – Knowing the specified function that a product has been designed to perform, test to see if that function is fully operational and error-free – Includes tests that are conducted at the software interface – Not concerned with internal logical structure of the software – Also called Functional Testing or Behavioral testing. White-box testing – Knowing the internal workings of a product, test that all internal operations are performed according to specifications and all internal components have been exercised – Involves tests that concentrate on close examination of procedural detail – Logical paths through the software are tested – Test cases exercise specific sets of conditions and loops – Also called Structural Testing or Glass-box testing 2 White-box Testing White-box Testing Uses the control structure part of component-level design to derive the test cases These test cases – Guarantee that all independent paths within a module have been exercised at least once – Exercise all logical decisions on their true and false sides – Execute all loops at their boundaries and within their operational bounds – Exercise internal data structures to ensure their validity 4 Basis Path Testing White-box testing technique proposed by Tom McCabe Enables the test case designer to derive a logical complexity measure of a procedural design Uses this measure as a guide for defining a basis set of execution paths Test cases derived to exercise the basis set are guaranteed to execute every statement in the program at least one time during testing 5 Flow Graph Notation A circle in a graph represents a node, which stands for a sequence of one or more procedural statements A node containing a simple conditional expression is referred to as a predicate node – Each compound condition in a conditional expression containing one or more Boolean operators (e.g., and, or) is represented by a separate predicate node – A predicate node has two edges leading out from it (True and False) An edge, or a link, is an arrow representing flow of control in a specific direction – An edge must start and terminate at a node – An edge does not intersect or cross over another edge Areas bounded by a set of edges and nodes are called regions When counting regions, include the area outside the graph as a region, too. 6 7 Flow Graph Example FLOW sCHART FLOW GRAPH t a r 1 R4 1t 2 3 R3 2 , 6 4 3 6 R2 7 8 5 4 7 R1 8 , 9 5 1 9 1 10 1 1 Independent Program Paths Defined as a path through the program from the start node until the end node that introduces at least one new set of processing statements or a new condition (i.e., new nodes) Must move along at least one edge that has not been traversed before by a previous path Basis set for flow graph on previous slide – Path 1: 1-11 – Path 2: 1-2-3-4-5-10-1-11 – Path 3: 1-2-3-6-8-9-10-1-11 – Path 4: 1-2-3-6-7-9-10-1-11 The number of paths in the basis set is determined by the cyclomatic complexity 9 Cyclomatic Complexity Provides a quantitative measure of the logical complexity of a program Defines the number of independent paths in the basis set Provides an upper bound for the number of tests that must be conducted to ensure all statements have been executed at least once Can be computed three ways – The number of regions – V(G) = E – N + 2, where E is the number of edges and N is the number of nodes in graph G – V(G) = P + 1, where P is the number of predicate nodes in the flow graph G 10 FLOW GRAPH Independent Paths 1 R4 Path 1: 1-11 Path 2: 1-2-3-4-5-10-1-11 Path 3: 1-2-3-6-8-9-10-1-11 Path 4: 1-2-3-6-7-9-10-1-11 R3 2 , 3 6 R2 Cyclomatic Complexity 4 7 R1 8 , Number of regions = 4 V(G) = 11 edges – 9 nodes + 2 = 4 5 V(G) = 3 predicate nodes + 1 = 4 9 1 1 i = 0; n=4; while (i 250} If an input condition specifies a member of a set, one valid and one invalid equivalence class are defined – Input set: {-2.5, 7.3, 8.4} Eq classes: {-2.5, 7.3, 8.4}, {any other x} If an input condition is a Boolean value, one valid and one invalid class are define – Input: {true condition} Eq classes: {true condition}, {false condition} 35 Equivalence partitioning is a testing technique where input values set into classes for testing. Valid Input Class = Keeps all valid inputs. Invalid Input Class = Keeps all Invalid inputs. Example: A text field permits only numeric characters, Length must be 6-10 characters long 36 Boundary Value Analysis A greater number of errors occur at the boundaries of the input domain rather than in the "center“ Boundary value analysis is a test case design method that complements equivalence partitioning – It selects test cases at the edges of a class – It derives test cases from both the input domain and output domain 37 Guidelines for Boundary Value Analysis 1. If an input condition specifies a range bounded by values a and b, test cases should be designed with values a and b as well as values just above and just below a and b 2. If an input condition specifies a number of values, test case should be developed that exercise the minimum and maximum numbers. Values just above and just below the minimum and maximum are also tested Apply guidelines 1 and 2 to output conditions; produce output that reflects the minimum and the maximum values expected; also test the values just below and just above If internal program data structures have prescribed boundaries (e.g., an array), design a test case to exercise the data structure at its minimum and maximum boundaries 38 Suppose you have very important tool at office, accepts valid User Name and Password field to work on that tool, and accepts minimum 8 characters and maximum 12 characters. Valid range 8-12, Invalid range 7 or less than 7 Invalid range 13 or more than 13. Test Cases 1: Consider password length less than 8. Test Cases 2: Consider password of length exactly 8. Test Cases 3: Consider password of length between 9 and 11. Test Cases 4: Consider password of length exactly 12. Test Cases 5: Consider password of length more than 12. 39 Example 1 for BVA & ECP Functional specification 1: In a multiuser software, users are connecting through a login process. Here users are given user id and password as inputs. i) user id accepts lowercase alphanumeric value between 4-16 characters long. ii) password accepts lower case Alphabets between 4-8 characters long. 40 Test scenario for verifying login id: user id accepts lowercase alphanumeric value between 4-16 characters long. Boundary Value Analysis(size) Minimum 4 chars Passed Maximum 16 chars Passed Minimum-1 3 chars Failed Maximum-1 15 chars Passed Minimum+1 5 chars Passed Maximum+1 17 chars Failed Equivalence Class Partitions (Type) Valid Cases Invalid Cases Alphanumeric in Upper case characters, Special characters, lower case Blank field 41 Test scenario for verifying Password: password accepts lower case Alphabets between 4-8 characters long. Boundary Value Analysis(size) Minimum 4 chars Passed Maximum 8 chars Passed Minimum-1 3 chars Failed Maximum-1 7 chars Passed Minimum+1 5 chars Passed Maximum+1 9 chars Failed Equivalence Class Partitions (Type) Valid Cases Invalid Cases Alphabets in Upper case characters, Special characters, lower case Blank field, numerics 42 Example 2 for BVA & ECP Functional specification 2: In an online banking software, users are connecting to bank server through a login process. The user should fill the following to login i) account number prefix🡪 3 digit number not starting with 0 or 1. ii) Account number suffix🡪6 digit number iii) Password🡪4 digit number 43 Test scenario for verifying account number prefix: account number prefix🡪 3 digit number not starting with 0 or 1. Boundary Value Analysis(size) Minimum 3 chars Passed Maximum 3 chars Passed Minimum-1 2 chars Failed Minimum+1 4 chars Failed Equivalence Class Partitions (Type) Valid Cases Invalid Cases [2-9][0-9][0-9] Upper & Lower case Alphabets, Special characters, Blank field 44 Test scenario for verifying account number suffix: Account number suffix🡪6 digit number Boundary Value Analysis(size) Minimum 6 chars Passed Maximum 6 chars Passed Minimum-1 5 chars Failed Minimum+1 7 chars Failed Equivalence Class Partitions (Type) Valid Cases Invalid Cases [0-9]{6} Upper & Lower case Alphabets, Special characters, Blank field 45 Test scenario for verifying password: Password🡪4 digit number Boundary Value Analysis(size) Minimum 4 chars Passed Maximum 4 chars Passed Minimum-1 3 chars Failed Minimum+1 5 chars Failed Equivalence Class Partitions (Type) Valid Cases Invalid Cases [0-9]{4} Upper & Lower case Alphabets, Special characters, Blank field 46 Walkthrough, Inspection& Peer Review Walkthrough: Study of a document from first to last for completeness & Correctness. Inspection: Searching a specific factor in document Peer Review: The comparison of two similar documents point to point for completeness & correctness 47 Error, Defect & Bug Error : An error is a mistake in coding found by developer. Defect: A defect is a mismatch in between expected value and actual value of software ,found by tester, sometimes defect is also known as issue or flaw. Bug: A Bug is a problem in software during utilization found by customers or users. 48