Software Testing Tutorial #19 - What is White Box Testing
Summary
TLDRThis tutorial explains white box testing, highlighting its differences from black box testing. Unlike black box testing, where the internal code isn't visible, white box testing focuses on the internal structure and code logic of the application. The video provides examples, such as a calculator application, to demonstrate how testing methods like statement coverage, branch coverage, condition coverage, loop testing, and path testing are applied. The tutorial emphasizes that white box testing is typically performed during unit and integration testing phases, with tools like JUnit used for verifying code coverage.
Takeaways
- 🧐 White box testing involves understanding the internal structure of the code, unlike black box testing where you only verify input and output.
- 💻 In white box testing, the tester has knowledge of the internal workings, such as methods and classes used in the functionality.
- 🔍 White box testing is also known as clear box, glass box, or structural testing, as it focuses on the internal code structure.
- 🧑💻 An example of white box testing is knowing the code behind a calculator, such as how addition or multiplication functions are implemented.
- 📑 Techniques in white box testing include statement coverage, branch coverage, condition coverage, loop testing, and path testing.
- ⚙️ White box testing is often used during unit testing and integration testing phases to ensure code-level functionality.
- 📊 Code coverage tools are used in white box testing to measure how much of the code has been exercised by test cases.
- 🔗 Developers usually perform white box testing by writing unit tests to cover different conditions and code paths.
- 🔧 White box testing involves verifying how the code handles various scenarios, including valid, invalid, and edge case inputs.
- 📚 Black box testing focuses on input-output verification without any knowledge of the internal code, while white box testing involves inspecting the code itself.
Q & A
What is white box testing?
-White box testing is a testing method where the internal structure, code, and implementation of the software are known to the tester. It involves verifying the internal workings of the code, such as methods, classes, and logic flow.
How does white box testing differ from black box testing?
-In black box testing, the tester does not have access to the internal workings of the software and focuses only on the inputs and outputs. In contrast, white box testing involves understanding and testing the internal code and structure of the application.
Can you give an example of black box testing?
-An example of black box testing is testing a user registration feature on an e-commerce website. The tester clicks the register button (input) and checks if the registration page is displayed correctly (output), without needing to know the internal code.
What are some common types of white box testing?
-Some common types of white box testing include statement coverage, branch coverage, condition coverage, loop testing, and path testing. These techniques ensure that all parts of the code are tested for correctness.
What is statement coverage in white box testing?
-Statement coverage ensures that every statement in the code has been executed and tested at least once during the testing process.
What is branch coverage in white box testing?
-Branch coverage checks that all possible branches of decision points (e.g., if-else conditions) are tested to ensure each branch executes as expected.
At what stages of testing is white box testing typically performed?
-White box testing is typically performed during unit testing and integration testing. In unit testing, small units of code are tested individually, while in integration testing, the interaction between different units is tested.
What tools are commonly used for white box testing?
-Tools such as JUnit for Java and other unit testing frameworks are commonly used for white box testing. These tools help in verifying code coverage, ensuring the different parts of the code are tested adequately.
How is white box testing applied to a calculator application?
-In a calculator application, white box testing would involve inspecting and testing the internal code for operations like addition, subtraction, multiplication, and division. The tester would verify how the code handles valid and invalid inputs.
What is loop testing in white box testing?
-Loop testing involves verifying that loops within the code function correctly under different conditions, such as with no iterations, a single iteration, or multiple iterations.
Outlines
🔍 Introduction to White Box Testing
This paragraph introduces white box testing, explaining the contrast between white box and black box testing. The speaker reviews black box testing, where the tester only provides input and verifies the output without knowing how the internal functionality works, using an example of a user registration process. White box testing is then introduced as a method that focuses on understanding the internal code and functionality, such as the methods and classes used for a given feature.
💻 White Box Testing and Code Access
The paragraph provides an example of white box testing using a calculator. The focus is on accessing the actual code to understand how operations like addition, subtraction, and other functions are implemented. A simple pseudo-code for addition is used to illustrate how white box testing involves testing code behavior with different types of inputs, such as valid and invalid values. The idea is to ensure the code functions correctly and handles edge cases, like invalid data inputs.
🧪 Techniques in White Box Testing
This section covers specific techniques used in white box testing, including statement coverage, branch coverage, condition coverage, loop testing, and path testing. These techniques ensure that all parts of the code are covered and tested. Various code coverage tools can help in this process, and the white box testing is generally done during unit and integration testing phases.
Mindmap
Keywords
💡White Box Testing
💡Black Box Testing
💡Statement Coverage
💡Branch Coverage
💡Condition Coverage
💡Loop Testing
💡Unit Testing
💡Integration Testing
💡Code Coverage Tools
💡E-commerce Example
Highlights
Introduction to white box testing and distinction from black box testing.
In black box testing, the tester has no access to the code and verifies functionality only based on input and output.
White box testing requires understanding of internal code structure, methods, and classes involved in a functionality.
White box testing is also referred to as clear box or structural testing.
Example of black box testing with an e-commerce user registration: testing by clicking buttons and verifying the expected outcomes.
In white box testing, the tester is concerned with the internal operations, such as methods or classes triggered after actions.
Example of white box testing using a calculator, focusing on how the code handles operations like addition and multiplication.
In white box testing, testers can examine code for addition, subtraction, multiplication, and division, checking its behavior with different inputs (valid/invalid).
White box testing includes techniques such as statement coverage, branch coverage, condition coverage, loop testing, and path testing.
Statement coverage ensures that all statements in the code are executed at least once by the test cases.
Branch coverage focuses on ensuring that every possible branch of a decision point in the code is tested.
Condition coverage ensures that each logical condition in a decision statement has been tested with true and false outcomes.
Loop testing verifies that loops within the code are executed properly, including boundary conditions and multiple iterations.
White box testing is typically done during unit testing and integration testing phases, often by developers.
Unit testing frameworks like JUnit are commonly used for white box testing to check code functionality at a granular level.
Transcripts
hello everyone welcome again in the
software testing tutorial
we are going to learn what is white box
testing
so we have already understood about the
black box testing now let us understand
what is white box testing because we
need to understand the difference
between white box and black box testing
so in this tutorial i'll explain
details about the white box testing so
that you know what
white box testing is and then the next
tutorial i'll complete
i'll complete the differences between
black box
and white box testing okay so as we have
understood about the black box testing
so
in the black box testing we didn't had
any access to the code or the
functionality that has been developed
right so this
say for example i'm testing any
functionality
uh i simply will provide the input
and based on the input i'll expect
certain output so
here i'll verify the output
right so if this is the case wherein i
don't have any knowledge of the internal
working of that functionality say for
example
user registration in the e-commerce
website when user clicks on register
after click on clicking on register
i only see the registration page being
displayed
for me right so when i click on register
that click is my input and when
the registration page is displayed with
all the fields that's my output right
so if i'm doing the black box testing
i'll click on register and
i'll verify that the registration page
is opening successfully or not
right so this is black box testing for
me now when we talk about
white box testing white box testing is
concerned about what actually happens
within this box right or
what happens in the actual code so say
for example if i click on register link
i need to have understanding of what
all happens within the code
which is being written for that
particular functionality right so
before this registration page is being
displayed
what all methods are being called what
all classes are being written so
depending on which programming language
you choose what implementation has been
done by the developer
if i am concerned about the details of
those
implementation then that is known as
white box
testing white box testing is also known
as class
box testing clear uh box testing
or structural testing right so uh when
you check
the structure of the code so it's in in
the structural testing there are many
types of
white box testing which will cover in
detail in upcoming tutorials
but as of now just understand when you
are the
when you want to understand the internal
working how the code how the methods are
written
which methods or which class calls which
class so all that details
uh when you are trying to test then that
is known as white box testing now let me
take an example of
white box testing and i'll explain you
know how
you can explain the white box testing to
the interviewer
now say for example i'll take very
simple example of calculator
okay say for example there is a website
all right
and uh on the website you have the
calculator
so usually what you'll do is you have
certain you know like numbers there
so you have the screen and you have
if you are accessing the the calculator
on the website so there will be the
sunscreen and
there will be you know like certain
numbers one two three uh
four five six seven eight nine right
and then plus minus uh multiplication
and division
and equal to sign so very simple so for
example i have taken the calculator
so if you are trying to test the
calculator
using the black box technique what you
will do is uh if you want to you know
test all the functionality you will test
the addition subtraction multiplication
and division right so this is simple
calculators what i'll do is i'll try a
couple of scenarios with the addition so
i'll say
seven i'll press seven and then plus
eight and then i'll verify
uh press equal to and verify that the
sum is what i
expect okay similarly if i want to
verify the subtraction multiplication
division i'll follow
the different scenarios or the test
cases to verify those scenarios
so this type of testing will be the
black box testing for me because
once i press seven and then plus press
plus and then press eight and equal to i
am not
concerned how internally that
calculation
is happening okay so
the internal working of this particular
calculator i don't know
and that is why this is black box for me
when i talk about the white box testing
the same calculator basically what i'll
do is
um i'll open the box right so
as it says white box in black box so in
the white box the box is open or it's
not a black
box for me uh i know
the internal working or i need to know
how the actual calculation happens so in
the white box testing you will
mostly work with the actual code right
so in that particular case what you will
do is
say for example i'll write
some pseudo code here so i have an
a number a a number b and
then say for example this is integer
integer and then there is another
integer
c and c is equal to a
plus b and then basically return
c so for example this is one of the
addition method that has been
implemented
as code right so if it is white box then
i know
that this is what the code has been
written for the additional functionality
similarly i'll have access
to the code that is implemented for the
multiplication for division
and similar will be the case in the
actual applications the complex
application say for example e-commerce
website
you will have access to the actual code
or the methods that are written
to perform a particular functionality or
the requirement if you're testing that
and you are verifying
the code within it how the code behaves
then that it will be white box testing
now in this white box testing what i'll
do is now
because i have access to code as well
i'll try to
test this particular you know code with
valid values invalid values
so i'll try with float i'll try with you
know invalid numbers
i'll try with with passing all other you
know negative scenarios and see
how this particular code behaves whether
it just
accepts integers and returns the integer
you know sum or multiplication etc
or it crashes if i provide some invalid
value
right so when you do this type of you
know verification
then that is white box testing i think
white box testing there are many
techniques so basically statement
coverage
so there are many types of testing so
the
statement coverage when you cover each
and every
you write the test case so that you
verify that the
statements all the statements in the
code are being covered
that is known as statement coverage um
then you have you know condition
coverage
loop coverage um and then you know like
paths testing or loop testing so all
those type of testing
will be part of the white box just
testing now let me write some of those
here as well so that you know so there
is statement
coverage and
the second important one is the branch
coverage
so when you verify the branch
the third important one to remember is
the condition coverage
then you have the loop
testing so you verify there are loops
different loops then you verify all the
loops are being exercised
with your test cases and then you have
you know path so different path testing
if there are multiple paths
say for example you have conditions then
you verify all those conditions right
so these are some of the techniques or
basically the coverage technique that
you will verify
and there are a lot of code coverage
tools available so when you write your
white box test cases
you most of the time this will be done
by the developers but as a tester
you will be required to basically
provide your inputs or
in case you know white box testing or
need to do in your organization then you
need to cover all this
you know white box testing techniques
you need to verify
that the code coverage or your test
cases have
or provide you the coverage of statement
branch condition
you know loop path all the code is being
exercised
in the white box testing now usually
you know white box testing will happen
uh in the unit test phase
okay so unit testing phase uh is where
the white box testing happens as well as
in the integration
testing okay so integration testing
it can happen in both phases because in
unit testing there will be small units
where which will be you know which
usually developers write the unit test
cases for and
there are you know unit test tools um
for example unit test framework for
example junit is very popular for java
and then integration testing you
integrate the units and make sure
after integration all these you know
statement branch coverage condition
coverage
loop and path testing is being done at
all
different levels all right so this is a
brief about
white box testing when you have
understanding and when you have
visibility of
what exactly happens when you
perform any operation or function on a
particular application in this case the
calculator when i press a
when i you know try to add two numbers
what exactly happens
within the code then that is white box
testing if
i don't have visibility of what happens
within the code
then that is known as black box testing
okay
so this is a brief about the white box
testing another example is of the
e-commerce
website so when i click on register link
after clicking on register link which
function got called
if i have the you know details or i have
the access to the actual code
when i click on register i can go into
the development
id and verify which
method got called and after that which
method got called
then that type of coverage and details
if i am verifying
with different test scenarios that i
write as part of the unit test or
integration test
in my code then that is white box
testing
all right so that's pretty much all
about the white box testing what white
box testing is
um different types of testing so
basically unit testing integration
testing you can do different
you know white box testing at different
levels
and then these are some of the coverage
or
the white box testing techniques that
will be utilized
in the white box testing so that's all
for this tutorial
hope it was helpful please do share and
subscribe and thank you very much for
watching
Weitere ähnliche Videos ansehen
ISTQB FOUNDATION 4.0 | Tutorial 36 | Value of White Box Test Techniques | CTFL Tutorials | TM SQUARE
Software Testing Tutorial #33 - Different Test Design Techniques
CH05.L01 . Black box or white box testing
ISTQB FOUNDATION 4.0 | Tutorial 34 | Statement Testing | Statement Coverage | Test Techniques | CTFL
L16 Unit Testing
ISTQB FOUNDATION 4.0 | Tutorial 35 | Branch Testing & Branch Coverage | Test Case Techniques | CTFL
5.0 / 5 (0 votes)