Black Box & White Box Testing

Explain the concept and need for non-functional testing. Support your answer with suitable examples.

What is Non-Functional testing?
  • It is the type of testing, which includes the non-functional requirements.
  • It verifies the attributes of the system such as memory leaks, performance of the system etc.
  • This type of testing is performed at all test levels.
  • The quality of the component or system is tested in non-functional testing.
Objectives of Non-Functional Testing
  • Improve quality of product.
  • Reduce the production risks and costs.
  • Optimize the product is installed, setup, configured, executes and managed.
  • Collect and produce measurement and metrics.
  • Support Ad-Hoc requests for testing.
  • Complete and enhance packet testing as a part of the product delivery readiness.
Need of Non-Functional Testing
  • Non-Functional Testing is designed to figure out if your product will provide a good user experience.
  • It determines how fast the product responds to a request or how long it takes to do an action.
  • It wants to see if the product stands up to customer expectations.
  • It wants to know that the product behaves correctly.
  • It needs to pass both categories of testing to ensure that the consumer has a good experience with the product, but if the working product is failed, then it damages the company's reputation and reduce overall product sales.
Non-Functional Testing Techniques:

Non Functional Testing Techniques
1. Baseline Testing
  • The requirement specification validation is baseline testing.
  • It refers to the validation of documents and specifications on which test cases would be designed.
2. Compatibility Testing
  • It is the testing of the application or the product built with the computing environment.
  • It tests whether the application or the software product built is compatible with the hardware, operating system, database or other system software or not.
3. Compliance Testing
  • It is related to the IT standards followed by the company.
  • It finds the deviations from the company prescribed standards.
4. Endurance Testing
  • It involves a system with a significant load extended over a period of time, to discover how the system behaves under sustained use.
5. Load Testing
  • It is usually conducted to understand the behavior of the application under a specific expected load.
  • It determines the system's behavior under both normal and at peak conditions.
  • It helps to identify the bottlenecks.
6. Performance Testing
  • It determines how fast some aspect of a system performs under a particular workload.
  • It can compare two systems to find which performs better.
7. Recovery Testing
  • It is used to check how fast and better the application can recover after it has gone through any type of crash or hardware failure etc.
  • It is the forced failure of the software in a variety of ways to verify that the recovery is properly performed.
8. Security Testing
  • It checks whether the application or the product is secured or not.
  • It determines that an information system protects data and maintains functionality as intended.
9. Scalable Testing
  • This testing measures its capability to scale up in terms of any of its non-functional capability like load supported, the number of transactions, the data volume etc.
10. Stress Testing
  • Stress testing is a form of testing that is used to determine the stability of a given system.
  • It involves testing beyond normal operational capacity, often to a breaking point, in order to observe the results.
11. Usability Testing
  • In Usability testing, the tester tests the ease with which the user interface can be used.
  • It tests whether the application or the product built is user-friendly or not.
12. Volume Testing
  • It refers to testing a software application or the product with a certain amount of data.
  • For example, if we want to volume test our application with a specific database size, we need to expand our database to that size and then test the application's performance on it.

Explain path, statement, branch and decision coverage in structural testing. Give examples for each.

  • The coverage can be measured at component testing, integration testing, system testing or acceptance testing levels.
  • For example, the coverage items may be requirements, menu options, business transactions, screens etc.
There are different types of coverage are as follows

A. Statement Coverage
B. Branch / Decision Coverage
C. Path Coverage
D. Condition Coverage

A. Path Coverage

What is Path Coverage?
  • It is a white box testing concept that acquires the possible paths of the software under test.
  • It represents the flow of execution from the start of the method of its exist.
  • It is used to create a graphical diagram of the code flow and follow each of the possible paths through every decision point.
B. Statement Coverage

What is Statement Coverage?
  • It is a white box technique which involves the execution of all the statements at least once in the source code.
  • It is also called as line coverage or segment coverage.
  • Statement Coverage is the metric which is used to calculate and measure the number of statements in the source code which have been executed.
  • It covers only the true conditions.
  • In this process each and every line of code needs to be checked and executed.
Advantages of Statement Coverage
  • It helps in assuring that all the statements execute without any side effect.
  • Statement Coverage verifies what the written code is expected to do and not to do.
  • It checks the flow of different paths in the program and also ensures that whether those paths are tested or not.
  • This coverage measures the quality of code written.
Disadvantages of Statement Coverage
  • The Statement Coverage cannot test the false conditions.
  • This coverage does not report that whether the loop reaches its termination condition.
  • The Statement Coverage does not understand the logical operators.
Formula for Statement Coverage
Statement Coverage =No. of Statements Exercisedx 100%
Total No. of Statements

C. Branch Coverage

What is Branch Coverage?
  • It is a testing method which ensures that each one of the possible branches from each decision point is executed at least once.
  • It is also known as Decision Coverage.
  • Branch Coverage takes a more in-depth view of the source code than simple statement coverage.
Advantages of Branch Coverage
  • It validates all the branches in the code are reached.
  • It ensures that no branches lead to any abnormality of the program's operation.
  • It eliminates the problems which occur with Statement Coverage.
Disadvantages of Branch Coverage
  • It ignores the branches within boolean expressions which occur due to short-circuit operators.
Formula for Branch / Decision Coverage
Branch Coverage / Decision Coverage = No. of Decision Outcomes Exercisedx 100%
Total No. of Decision Outcomes

Example of Statement Coverage, Path Coverage and Branch / Decision Coverage

Algorithm
Read A
Read B

IF A > B THEN
Print “A is Large”
ENDIF

IF A < B THEN
Print “B is Large”
ENDIF

Flow Chart

Coverage Example

1. Statement Coverage:
  • To calculate Statement Coverage, find out the shortest number of paths following which all the nodes will be covered.
  • Traversing Path : 1A – 2C – 3D – 4G – 5H (All these nodes are covered)
    All the nodes are : 1 2 3 4 5
    Statement Coverage is : 1
2. Branch Coverage:
  • To calculate Branch Coverage, find out the minimum number of paths which ensures that covering of all the edges.
  • In the above flow chart, there is no single path which ensures the coverage of all the edges at one go.
  • Paths : 1A – 2C – 3D – E – 4G – 5H
    Maximum no. of edges : A, C, D, E, G, H
    All the edges are covered except B and F.
    To cover B and F edges, use : 1A – 2B – E – 4F
  • Branch Coverage has one main aim to cover all possible true / false decisions.
  • So, the Branch Coverage is : 2
3. Path Coverage
  • It ensures that covering of all the paths from start to end.
  • All the possible paths are
  • 1A – 2B – E – 4F

    1A – 2B – E – 4G – 5H

    1A – 2C – 3D – E – 4G – 5H

    1A – 2C – 3D – E – 4F
  • So, the Path Coverage is : 4
Statement Coverage (SC) = 1
Branch Coverage (BC) = 2
Path Coverage (PC) = 4

Write a short note on Equivalence Partitioning.

What is Equivalence Partitioning?
  • It is a software testing technique which divides the input data of a software unit into partitions of equivalent data from which the test cases can be derived.
  • It is a specification based or black box testing technique.
  • It is also called as Equivalence Class Partitioning or ECP.
  • The main advantages of this technique is that, it reduces the time required for performance testing of a software due to less number of test cases.
  • 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.
Guidelines of Equivalence Partitioning
  • If an input condition specifies a range, one valid and one, two invalid classes are defined.
  • If an input condition requires a specific value, one valid and two invalid equivalence classes are defined.
  • If an input condition specifies a member of a set, one valid and one invalid equivalence class is defined.
  • If an input condition is boolean, one valid and one invalid class is defined.
Example of Equivalence Partitioning:
  • Following example defines the awarding grades to the students.

  • MarksGrade
    00 - 39D
    40 - 59C
    60 - 70B
    71 - 100A

  • Based on the Equivalence Partitioning technique, the partitions of the above example as follows:

  • MarksValid PartitionInvalid Partition
    Between 00 - 39Valid
    Between 40 - 59Valid
    Between 60 - 70Valid
    Between 71 - 100Valid
    Less than 0Invalid
    More than 100Invalid
    Non numeric inputInvalid

  • In the above example, it is clear that from infinite possible test cases, data can be divided into seven distinct classes.
  • This shows a very important task of the tester that is a tester should not only test what is in the specification, but should also think about things that have not been specified.
  • In equivalence-partitioning technique we need to test only one condition from each partition. This is because we are assuming that all the conditions in one partition will be treated in the same way by the software. If one condition in a partition works, we assume all of the conditions in that partition will work, and so there is little point in testing any of these others. Similarly, if one of the conditions in a partition does not work, then we assume that none of the conditions in that partition will work so again there is little point in testing any more in that partition.
  • Equivalence Partition is used to minimize the number of permutation and combination of input data.
  • The data is selected in such a way that it gives as many different output as possible with the minimal set of data.

Write a short note on Black Box Vs White Box Testing.

Black Box Vs White Box Testing.

Sr. No.Black Box TestingWhite Box Testing
1.It is used to test the software without knowing the internal structure of the code or the program.The internal structure is being known to the tester who is going to test the software.
2.It is carried out by testers.It is carried out by software developers.
3.Implementation knowledge is not required to carry out Black Box Testing.Implementation knowledge is required to carry out White Box Testing.
4.Programming knowledge is not required to carry out Black Box Testing.Programming knowledge is required to carry out White Box Testing.
5.It concentrates on the functionality of the system under test.It concentrates on the testing of the program code of the system under test like code structure, branches, conditions, loops etc.
6.It can be started based on the Requirement Specification documents.It can be started based on the detail design documents.
7.This testing means functional test or external testing.This testing means structural test or interior testing.
8.It is applicable to higher levels of testing like Acceptance Testing, System Testing.It is applicable to lower levels of testing like Unit Testing, Integration Testing.
9.The tester focuses on the functionality of the system.The developer focuses on the structure means the program or code of the system.
10.It looks at what are the available inputs for an application and what the expected outputs are that should result from each input.It looks under the covers and into the subsystem of an application.