SOFTWARE TESTING APPROACHES Black-Box and White-Box Testing Dr. Baisakhi Chakraborty BLACK BOX TESTING • It is also called as Behavioural/SpecificationBased/Input-Output Testing • Black Box Testing is a software testing method in which testers evaluate the functionality of the software under test without looking at the internal code structure. This can be applied to every level of software testing such as – Unit, – Integration, – System, and – Acceptance Testing. • The tester performs testing only on the functional part of an application to make sure the behaviour of the software as expected. • The tester passes input data to make sure whether the actual output matches the expected output. So it is called Input-Output Testing. • Test cases are decided solely on the basis of the requirements or specification of the program or module. The internals of the program or modules are not considered. Black Box Testing Techniques • Equivalence Partitioning • Boundary Value Analysis • Decision Table • State Transition • Error guessing Equivalence Partitioning • Equivalence Partitioning is also known as Equivalence Class Partitioning. • In equivalence partitioning, inputs to the software or system are divided into groups that are expected to exhibit similar behaviour, so they are likely to be proposed in the same way. • Hence selecting one input from each group to design the test cases. • Each and every condition of particular partition (group) works as same as other. If a condition in a partition is valid, other conditions are valid too. If a condition in a partition is invalid, other conditions are invalid too. • It helps to reduce the total number of test cases from infinite to finite. The selected test cases from these groups ensure coverage of all possible scenarios. • Equivalence partitioning is applicable at all levels of testing. • In short, it is the process of taking all possible test cases and placing them into classes. One test value is picked from each class while testing. • For Example, If you are testing for an input box accepting numbers from 1 to 10000 then there is no use in writing ten thousand test cases for all 10000 valid input numbers plus other test cases for invalid data. • Using the Equivalence Partitioning method above test cases can be divided into three sets of input data called classes. Each test case is representative of a respective class. • So in the above example, we can divide our test cases into three equivalence classes of some valid and invalid inputs. • Test cases for input box accepting numbers between 1 and 100 using Equivalence Partitioning • 1) One input data class with all valid inputs. Pick a single value from range 1 to 100 as a valid test case. If you select other values between 1 and 100 the result is going to be the same. So one test case for valid input data should be sufficient. • 2) Input data class with all values below the lower limit. I.e. any value below 1, as an invalid input data test case. • 3) Input data with any value greater than 100 to represent the third invalid input class. • So using Equivalence Partitioning you have categorized all possible test cases into three classes. Test cases with other values from any class should give you the same result. • We have selected one representative from every input class to design our test cases. Test case values are selected in such a way that largest number of attributes of equivalence class can be exercised. • Equivalence Partitioning uses fewest test cases to cover maximum requirements. Example on Equivalence Partitioning Test Case Design Technique • Assume, we have to test a field which accepts Age 18 – 56 • Valid Input: 18 – 56 • Invalid Input: less than or equal to 17 (<=17), greater than or equal to 57 (>=57) • Valid Class: 18 – 56 = Pick any one input test data from 18 – 56 • Invalid Class 1: <=17 = Pick any one input test data less than or equal to 17 • Invalid Class 2: >=57 = Pick any one input test data greater than or equal to 57 • We have one valid and two invalid conditions here. Test cases for input box accepting values that limit characters between 1 and 100 using Equivalence Partitioning • There would be 3 partitions: 1 valid, 2 invalid • The valid partition: Between 1 & 100 characters. • The expectation is that the text field would handle all inputs with 1-100 characters, the same way. • The first invalid partition: 0 characters. • When no characters are entered, we’d expect the text field to reject the value. • The second invalid partition: ≥ 101 • We’d expect the text field to reject all values greater than or equal to 101 characters • Consider a sample web page which consists of first name, last name, and email text fields with radio buttons for gender which use Boolean inputs. • If the user clicks on any of the radio buttons, the corresponding value should be set as the input. If the user clicks on a different option, the value of input needs to be updated with the new one (and the previously selected option should be deselected). • Here, the instance of a radio button option being clicked can be treated as TRUE and the instance where none are clicked, as FALSE. Also, two radio buttons should not get selected simultaneously; if so, then it is considered as a bug. 2.Practice Method: Note: If there is deviation in between the range of values, then use Practice Method. If there is no deviation between the range of values, then use Pressman Rule. BOUNDARY VALUE ANALYSIS • Programs that work correctly for a set of values in an equivalence class fail on some values that often lie on the boundary of equivalence class. • In BVA, we choose an input for a test case from an equivalence class, such that the input lies at the edge of the equivalence class. BVA test cases are also called extreme cases. For ex: If the range of the equivalence class is 0.0 x 1.0, then the test cases may be 0.0,1.0 which are the boundary values. Boundary Value Analysis • It’s widely recognized that input values at the extreme ends of the input domain cause more errors in the system. Boundary value analysis (BVA) is based on testing the boundary values of valid and invalid partitions. The Behaviour at the edge of each equivalence partition is more likely to be incorrect than the behaviour within the partition, so boundaries are an area where testing is likely to yield defects. • More application errors occur at the boundaries of the input domain. ‘Boundary Value Analysis’ Testing technique is used to identify errors at boundaries rather than finding those that exist in the centre of the input domain. • Boundary Value Analysis is the next part of Equivalence Partitioning for designing test cases where test cases are selected at the edges of the equivalence classes. • Test cases for input box accepting numbers between 1 and 1000 using Boundary value analysis: • #1) Test cases with test data exactly as the input boundaries of input domain i.e. values 1 and 1000 in our case. • #2) Test data with values just below the extreme edges of input domains i.e. values 0 and 999 (or 0.999 0r 0.9). • #3) Test data with values just above the extreme edges of the input domain i.e. values 2 and 1001 (or 1.999 09 1.9). • Boundary Value Analysis is often called as a part of the Stress and Negative Testing. • Note: There is no hard-and-fast rule to test only one value from each equivalence class you created for input domains. You can select multiple valid and invalid values from each equivalence class according to your needs and previous judgments. • Consider an example where a developer writes code for an amount text field which will accept and transfer values only from 100 to 5000. The test engineer checks it by entering 99 into the amount text field and then clicks on the transfer button. It will show an error message as 99 is an invalid test case, because the boundary values are already set as 100 and 5000. Since 99 is less than 100, the text field will not transfer the amount. • The valid and invalid test cases are listed below. • Valid Test Cases • Enter the value 100 which is min value. • Enter the value 101 which is min+1 value. • Enter the value 4999 which is max-1 value. • Enter the value 5000 which is max value. • Invalid Test Cases • Enter the value 99 which is min-1 value. • Enter the value 5001 which is max+1 value • (You can enter the min and max values as per your choice, it may be integers, decimal, float, double etc.) • Every partition has its maximum and minimum values and these maximum and minimum values are the boundary values of a partition. • A boundary value for a valid partition is a valid boundary value. Similarly a boundary value for an invalid partition is an invalid boundary value. • Tests can be designed to cover both valid and invalid boundary values. When designing test cases, a test for each boundary value is chosen. • For each boundary, we test +/-1 in the least significant digit of either side of the boundary. • Boundary value analysis can be applied at all test levels. Example on Boundary Value Analysis Test Case Design Technique Test a field which accepts Age 18 – 56 Minimum boundary value is 18 Maximum boundary value is 56 Valid Inputs: 18,19,55,56 Invalid Inputs: 17 and 57 Test case 1: Enter the value 17 (18-1) = Invalid Test case 2: Enter the value 18 = Valid Test case 3: Enter the value 19 (18+1) = Valid Test case 4: Enter the value 55 (56-1) = Valid Test case 5: Enter the value 56 = Valid Test case 6: Enter the value 57 (56+1) =Invalid • Test a text field (Name) which accepts the length between 6-12 characters Minimum boundary value is 6 Maximum boundary value is 12 Valid text length is 6, 7, 11, 12 Invalid text length is 5, 13 Test case 1: Text length of 5 (min-1) = Invalid Test case 2: Text length of exactly 6 (min) = Valid Test case 3: Text length of 7 (min+1) = Valid Test case 4: Text length of 11 (max-1) = Valid Test case 5: Text length of exactly 12 (max) = Valid Test case 6: Text length of 13 (max+1) = Invalid • BVA complements E.C. partitioning. BVA leads to selection of test cases at the edges of an E.C. Rather than solely driving test cases from input conditions only, it also focuses on deriving test cases from output conditions. General guidelines for deriving BVA test cases: • If an input condition specifies a range bounded by values a & b, test cases should be designed with values a & b & just above & below a & b • If an input condition specifies a number of values, test cases should be developed that exercise the min & max numbers. Values just above & below max & min are also tested. • Apply rules 1 & 2 to the output conditions. • If internal program data structures have prescribed boundaries,(e.g. an array has a defined limit of 100 entries), be certain to design a test cases to exercise the data structure as its boundary. Summary of EQ partitioning and BVA • Boundary Value Analysis is better than Equivalence Partitioning as it considers both positive and negative values along with maximum and minimum value. So, when compared with Equivalence Partitioning, Boundary Value Analysis proves to be a better choice in assuring the quality. • Software testing Techniques allow you to design better test cases. There are five primarily used techniques. • Boundary value analysis is testing at the boundaries between partitions. • Equivalent Class Partitioning allows you to divide set of test condition into a partition which should be considered the same. Decision Table Test case Design • Decision table testing is a software testing technique used to test system behaviour for different input combinations. This is a systematic approach where the different input combinations and their corresponding system behaviour (Output) are captured in a tabular form. • Decision Table is aka Cause-Effect Table. CAUSE AND EFFECTS ARE CAPTURED FOR BETTER COVERAGE • This test technique is appropriate for functionalities which has logical relationships between inputs (if-else logic). • It deals with combinations of inputs. • To identify the test cases with decision table, we consider conditions and actions. We take conditions as inputs and actions as outputs. • Decision Table is a tabular representation of inputs versus rules/cases/test conditions. • It is a very effective tool used for both complex software testing and requirements management. • Decision table helps to check all possible combinations of conditions for testing and testers can also identify missed conditions easily. • The conditions are indicated as True(T) and False(F) values. Examples on Decision Table Test Case Design Technique Exercise: Transfer money online to an account which is already added and approved • Here the conditions to transfer money are – ACCOUNT ALREADY APPROVED, – OTP (One Time Password) MATCHED, – SUFFICIENT MONEY IN THE ACCOUNT. • And the actions performed are – TRANSFER MONEY, – SHOW A MESSAGE AS INSUFFICIENT AMOUNT, – BLOCK THE TRANSACTION INCASE OF SUSPICIOUS TRANSACTION. • We need to see under what condition the action will take place. Refer the Table in the next slide. • The conditions and actions related to the requirement are taken in a column. All the other columns represent Test Cases (except ID col.). • T = True, F = False, X = Not possible • From the case 3 and case 4, if condition 2 fails, then system will execute Action 3. So either of case 3 or case 4 may be executed. Final Decision Table 4 test cases are written for this exercise Login Page validation example • Allow user to login only when both the ‘User ID’ and ‘Password’ are entered correct. • Conditions: – 1. Enter Valid User Name and – 2. Enter Valid Password. • The Actions performed: – Displaying home page and – Displaying an error message that User ID or Password is wrong. From the case 2 and case 3, we could identify that if one of the condition failed then the system will display an error message as Invalid User Credentials. So I am eliminating one of the test case from case 2 and case 3 and concluding with the below tabular column. Importance of Decision Table testing • Decision Table Testing is Important because it helps to test different combinations of conditions and provide better test coverage for complex business logic. • When testing the behaviour of a large set of inputs where system behaviour differs with each set of input, decision table testing provides good coverage and the representation is simple so it is easy to interpret and use. • In Software Engineering, boundary value and equivalent partition are other similar techniques used to ensure better coverage. They are used if the system shows the same behaviour for a large set of inputs. However, in a system where for each set of input values the system behaviour is different, boundary value and equivalent partitioning technique are not effective in ensuring good test coverage. Importance of Decision Table testing • In this case, decision table testing is a good option. This technique can make sure of good coverage, and the representation is simple so that it is easy to interpret and use. • This table can be used as the reference for the requirement and for the functionality development since it is easy to understand and cover all the combinations. • The significance of this technique becomes immediately clear as the number of inputs increases. Number of possible Combinations is given by 2 ^ n , where n is the number of Inputs. For n = 10, which is very common in the web based testing, having big input forms, the number of combinations will be 1024. Obviously, you cannot test all but you will choose a rich sub-set of the possible combinations using decision based testing technique. Advantages of Decision Table Testing • When the system behaviour is different for different input and not same for a range of inputs, both equivalent partitioning, and boundary value analysis won't help, but decision table can be used. • The representation is simple so that it can be easily interpreted and is used for development and business as well. • This table will help to make effective combinations and can ensure a better coverage for testing • Any complex business conditions can be easily turned into decision tables • In a case we are going for 100% coverage typically when the input combinations are low, this technique can ensure the coverage. Disadvantages of Decision Table Testing The main disadvantage is that when the number of input increases the table will become more complex State Transition Testing • It is a BB Testing technique, in which outputs are triggered by changes to the input conditions or changes to 'state' of the system. In other words, tests are designed to execute valid and invalid state transitions • When to use? – When we have sequence of events that occur and associated conditions that apply to those events – When the proper handling of a particular event depends on the events and conditions that have occurred in the past – It is used for real time systems with various states and transitions involved State Transition Test Case Design Technique • Using state transition testing, we pick test cases from an application where we need to test different system transitions. We can apply this when an application gives a different output for the same input, depending on what has happened in the earlier state. • Some examples are Vending Machine, Traffic Lights. • Vending machine dispenses products when the proper combination of coins is deposited. • Traffic Lights will change sequence when cars are moving / waiting Deriving Test cases • Understand the various state and transition and mark each valid and invalid state • Defining a sequence of an event that leads to an allowed test ending state • Each one of those visited state and traversed transition should be noted down • Steps 2 and 3 should be repeated until all states have been visited and all transitions traversed • For test cases to have a good coverage, actual input values and the actual output values have to be generated Example on State Transition Test Case Design Technique • Example of login page of an application which locks the user name after three wrong attempts of password. • It works like a truth table. First determine the states, input data and output data. Entering correct password in the first attempt or second attempt or third attempt, user will be redirected to the home page (i.e., State – S4). Entering incorrect correct password in the first attempt, a message will be displayed as try again and user will be redirected to state S2 for the second attempt. Entering incorrect correct password in the second attempt, a message will be displayed as try again and user will be redirected to state S3 for the third attempt. Entering incorrect correct password in the third attempt, user will be redirected to state S5 and a message will be displayed as “Account locked. Consult Administrator”. Another Example • Withdrawal of money from ATM. • ‘User A’ wants to withdraw 30,000 from ATM. Imagine he could take 10,000 per transaction and total balance available in the account is 25,000. In the first two attempts, he could withdraw money. Whereas in the third attempt, ATM shows a message as “Insufficient balance, contact Bank”. • Same Action but due to change in the state, he couldn’t withdraw the money in the third transaction. • In the flight reservation login screen, consider you have to enter correct agent name and password to access the flight reservation application. State Transition Graph • It gives you the access to the application with correct password and login name, but what if you entered the wrong password. • The application allows three attempts, and if users enter the wrong password at 4th attempt, the system closes the application automatically. • The State Graphs helps you determine valid transitions to be tested. In this case, testing with the correct password and with an incorrect password is compulsory. For the test scenarios, log-in on 2nd, 3rd and 4th attempt anyone could be tested. • You can use State Table to determine invalid system transitions. • In a State Table, all the valid states are listed on the left side of the table, and the events that cause them on the top. • Each cell represents the state system will move to when the corresponding event occurs. • For example, while in S1 state you enter a correct password you are taken to state S6 (Access Granted). Suppose if you have entered the wrong password at first attempt you will be taken to state S3 or 2nd Try. • Likewise, you can determine all other states. • Two invalid states are highlighted using this method. Suppose you are in state S6 that is you are already logged into the application, and you open another instance of flight reservation and enter valid or invalid passwords for the same agent. System response for such a scenario needs to be tested. • Black-box testing Summary WHITE-BOX TESTING • So the final TEST SET for 100% decision coverage will be: • TEST CASE 1: X=10, Y=5 • TEST CASE 2: X=2, Y=10 • Note: 100% decision coverage guarantees 100% statement coverage but 100% statement coverage does not guarantee 100% decision coverage. PATH COVERAGE 3.Path coverage: The basis path method enables the test-case designer to derive a logical complexity measure of a procedural design and use 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. Example of Path Coverage Advantages and Disadvantages of WB Testing ACKNOWLEDGEMENTS • https://www.softwaretestingmaterial.com/softw are-testing/ • https://www.inflectra.com/ideas/topic/testingmethodologies.aspx • Black-box and white-box testing by Garima Pathak • White-box testing by Adil Aslam • Black-Box and Grey-box testing by Yisal Khan • Roger Pressman
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )