Chapter 8: Black Box and White Box Testing

What is Black Box Testing?

Black Box Testing is also known as behavioral, opaque-box, closed-box, specification-based or eye-to-eye testing.It is a Software Testing method that analyses the functionality of a software/application without knowing much about the internal structure/design of the item that is being tested and compares the input value with the output value.

The main focus in Black Box Testing is on the functionality of the system as a whole. The term ‘Behavioral Testing’ is also used for Black Box Testing.There are some bugs that cannot be found using the only black box or only white box technique.

Majority of the applications are tested by Black Box method. We need to cover the majority of test cases so that most of the bugs will get discovered by a Black-Box method.This testing occurs throughout the software development and Testing Life Cycle i.e in Unit, Integration, System, Acceptance, and Regression Testing stages.This can be both Functional or Non-Functional.

Types Of Black Box Testing

Practically, there are several types of Black Box Testing that are possible but if we consider the major form of it then below mentioned are the two fundamental ones.

Functional Testing and Nonfunctional Testing

 Functional Testing

This type deals with the functional requirements or specifications of an application. Here, different actions or functions of the system are being tested by providing the input and comparing the actual output with the expected output.

For Example, when we test a Dropdown list, we click on it and verify that it expands and all the expected values are showing in the list.

Few major types of Functional Testing are:

  • Smoke Testing
  • Sanity Testing
  • Integration Testing
  • System Testing
  • Regression Testing
  • User Acceptance Testing

 Non-Functional Testing

Apart from the functionalities of the requirements, there are several non-functional aspects as well that are required to be tested to improve the quality and performance of the application.

Few major types of Non-Functional Testing include:

  • Usability Testing
  • Load Testing
  • Performance Testing
  • Compatibility Testing
  • Stress Testing
  • Scalability Testing

Black Box Testing Techniques

In order to systematically test a set of functions, it is necessary to design test cases. Testers can create test cases from the requirement specification document using the following Black Box Testing techniques.

  • Equivalence Partitioning
  • Boundary Value Analysis
  • Decision Table Testing
  • State Transition Testing
  • Error Guessing
  • Graph-Based Testing Methods
  • Comparison Testing

Let us understand each technique in detail.

Equivalence Partitioning

This technique is also known as Equivalence Class Partitioning (ECP). In this technique, input values to the system or application are divided into different classes or groups based on its similarity in the outcome.

Hence, instead of using each and every input value we can now use any one value from the group/class to test the outcome. In this way, we can maintain the test coverage while we can reduce a lot of rework and most importantly the time spent.

Boundary Value Analysis

From the name itself, we can understand that in this technique we focus on the values at boundaries as it is found that many applications have a high amount of issues on the boundaries.

Boundary means the values near the limit where the behavior of the system changes. In boundary value analysis both the valid inputs and invalid inputs are being tested to verify the issues.

For Example:If we want to test a field where values from 1 to 100 should be accepted then we choose the boundary values: 1-1, 1, 1+1, 100-1, 100, and 100+1. Instead of using all the values from 1 to 100, we just use 0, 1, 2, 99, 100, and 101.

Decision Table Testing

As the name itself suggests that, wherever there are logical relationships like:

If
{
(Condition = True)
then action1 ;
}
else action2; /*(condition = False)*/

Then a tester will identify two outputs (action1 and action2) for two conditions (True and False). So based on the probable scenarios a Decision table is carved to prepare a set of test cases.

State Transition Testing

State Transition Testing is a technique that is used to test the different states of the system under test. The state of the system changes depending upon the conditions or events. The events trigger states which become scenarios and a tester needs to test them.

A systematic state transition diagram gives a clear view of the state changes but it is effective for simpler applications. More complex projects may lead to more complex transition diagrams thus making it less effective.

Few common mistakes that  developers usually forget to handle:

  • Divide by zero.
  • Handling null values in text fields.
  • Accepting the Submit button without any value.
  • File upload without attachment.
  • File upload with less than or more than the limit size.

How to do Step-wise?

In general, when a systematic process is followed to test a project/application then quality is maintained and is useful in the long run for further rounds of testing.

  • The foremost step is to understand the Requirement specification of an application. A proper documented SRS(Software Requirement Specification) should be in place.
  • Using the above mentioned Black Box Testing techniques such as Boundary Value Analysis, Equivalence partitioning etc sets of valid and invalid inputs are identified with their desired outputs and test cases are designed based on that.
  • The designed test cases are executed to check if they Pass or Fail by verifying the actual results with the expected results.
  • The Failed test cases are raised as Defects/Bugs and addressed to the development team to get it Fixed.
  • Further based on the defects being fixed, the tester Retests the defects to verify if it is recurring or not.

Advantages and Disadvantages

Advantages

  • The tester need not have a technical background. It is important to test by being in the user’s shoes and think from the user’s point of view.
  • Testing can be started once the development of the project/application is done. Both the testers and developers work independently without interfering in each other’s space.
  • It is more effective for large and complex applications.
  • Defects and inconsistencies can be identified at the early stage of testing.

Disadvantages

  • Without any technical or programming knowledge, there are chances of ignoring possible conditions of the scenario to be tested.
  • In a stipulated time there are possibilities of testing less and skipping all possible inputs and their output testing.
  • A Complete Test Coverage is not possible for large and complex projects.

White Box Testing:

It is also called as Glass Box, Clear Box, Structural Testing.

White Box Testing is based on applications internal code structure. In white-box testing an internal perspective of the system, as well as programming skills, are used to design test cases. This testing usually done at the unit level.

White Box Testing Techniques:

  1. Statement Coverage
  2. Branch Coverage
  3. Path Coverage

Difference Between White Box Testing And Black Box Testing

Black Box TestingWhite Box Testing
It is a testing method without having knowledge about the actual code or internal structure of the applicationIt is a testing method having knowledge about the actual code and internal structure of the application
This is a higher level testing such as functional testing.This type of testing is performed at a lower level of testing such as Unit Testing, Integration Testing
It concentrates on the functionality of the system under testIt concentrates on the actual code – program and its syntax’s
Black box testing requires Requirement specification to testWhite Box testing requires Design documents with data flow diagrams, flowcharts etc.
Black box testing is done by the testersWhite box testing is done by Developers or testers with programming knowledge.