White-box testing becomes possible when a tester has access to the application’s source code and the expertise to analyze it.
Its opposite is black-box testing, where a tester only has access to the external shell — the application interface.
White-box testing becomes possible when a tester has access to the application’s source code and the expertise to analyze it.
Its opposite is black-box testing, where a tester only has access to the external shell — the application interface.
The service, depending on the value passed in the taste parameter, returns one list of candies or another.
candies(taste) {
if taste equals MINT ignoring case {
then return response ["Космическая свежесть", "Мятная туманность"]
}
else if taste equals CITRUS ignoring case {
then return response ["Взрывная Комета"]
}
else return response ["Вселенская Гармония"]
}
Square brackets [ ] represent an array of homogeneous data — in our case, a list of candy names.
The main white-box testing techniques are:
Condition testing
if (taste == MINT or taste == CITRUS) {
process();
} else {
processDefault();
}
Checks different states and combinations of conditions, including each part of complex conditions.
Path testing
if (taste == MINT or taste == CITRUS) {
process(); //may cause an error
} else {
processDefault();
}
Checks all possible execution paths in the program.
Covers the checks from condition testing and can also take into account scenarios where an exceptional situation occurs during code execution.
Code coverage testing
if (taste == MINT or taste == CITRUS) {
process();
} else {
processDefault();
}
Aims to execute every line of code at least once during testing.
A line is considered covered even if only part of the condition was evaluated. Learn more.
Arrange the techniques in order of increasing number of checks.
To make it clearer, let’s build a flowchart based on the logic described in the original pseudocode.
if, else if and else are conditional operators.
Each condition (MINT, CITRUS) can be true (yes) or false (no) — these are the possible states of the condition.
The transition to checking the CITRUS condition occurs only if the state of the MINT condition is false (no).
Let’s list all possible combinations of condition states in a table.
These are the checks that need to be performed when using condition testing.
| Check | Condition MINT | Condition CITRUS |
|---|---|---|
| 1 | yes | — |
| 2 | no | yes |
| 3 | no | no |
Уровень повышен!