White Box Testing and Black Box Testing in Software Testing
Friday November 25, 2011
Software testing is one of the best means to affirm the quality of software and deliver an error-free application. Over the years, software testing has matured into a separate discipline giving way to several different testing techniques that have been introduced, analyzed and studied in this area. Black box testing and white box testing are two such testing approaches that are quite commonly used by software testers.
What is Black Box Testing?
Crudely put, when the tester has no idea of the internal working of the system which he is testing, that approach is called black box testing.
In this case, the system under test is viewed as a “black box”.
Requirements Document or Functional Specification Document forms the basis of this testing, which requires the user to understand the processes within the software.
How to write Test Cases for Black Box Testing?
- The tester examines requirements and specifications of the system.
- The tester explores the system’s UI and functionality to understand how the processes on the system are expected to work.
- Tester designs test cases with valid inputs and the corresponding expected outputs.
- Tester also includes some negative test cases with invalid inputs and expected outputs (error messages/program termination) as applicable.
Techniques of Black Box Testing
In case of black box testing, inputs to the test cases are the driving factor. Any one of the three techniques discussed below can be used to choose the inputs during the black box testing process
- Boundary Value Analysis: This approach is focused on testing the boundary values associated with the system. This approach aims at testing the boundaries of the input domain that have the highest probability of giving erroneous outputs.
- Equivalence Class Partitioning: In this approach, a limited set of functions is identified along with its corresponding valid and invalid inputs and expected outputs. This approach aims at identifying classes of errors and therefore reducing the number of test cases required.
- Error Guessing: An experienced tester most often uses this approach to first identify the defects and then develop corresponding test cases.
What is White Box Testing?
In white box testing methodology, the tester has the knowledge of the internals of a system and knows how the system is implemented. The tester uses this knowledge to develop test cases that will examine the control flow, information flow, data flow, exception and error handling as well as coding practices of the system.
How to write Test Cases for White Box Testing?
- The tester analyzes and understands the structure of the system by examining its code.
- The tester understands the weak spots within the code that is most prone to defects.
- The tester develops test cases to cover individual data/information/ control flows and branches within the code.
- The tester also develops test cases to test proper working of all the functionalities and error handing of the system.
Techniques of White Box Testing
When it comes to white box testing, the knowledge that the tester possesses about the system is the driving factor, which helps the tester to devise test cases aimed at discovering defects with the internal working of the system.
- Statement Tests: All the statements within the code must have a test case associated with it such that each statement must be executed at least once during the testing cycle.
- Decision Tests: All the decision directions must be executed at least once during the testing life cycle.
- Branch Condition Tests: All the conditions in a specific decision must be tested for proper working at least once.
- Decision/Condition Tests: All the combination of the possible conditions within a specific decision for all the decisions is to be tested.
- Data Flow Tests: This will ensure that all the variables and data that are used within the system are tested by passing the specific variables through each possible calculation.
- Multiple Condition Tests: This will ensure that each point of entry with in the code is tested at least once during the testing life cycle.
What is Grey Box Testing?
This is an approach that lies between white box and black box testing. In this, the test cases are written with the knowledge of internal source code of the application. However, the testing is done at the interface level only.
Download the Enterprise Version of TestingWhiz Now!