White Box Analysis and JUnit Testing Guide
White Box Analysis and JUnit Testing Guide
oGrafo:
Cyclomatic complexity:
Test paths:
Limit values:
Atributo: cantidad
Domain Class Type Lower limit Upper limit
Decimal numbers with (-∞, 0] Invalid -∞ 0
floating point (double)
(0,≤dBalance ] Valid 0 <=dBalance
(> dSaldo, +∞) Not valid Balance +∞
Test design:
Method: withdraw
No test amount to withdraw Expected output
1 -100 ERROR
2 -1 ERROR
3 0 balance = balance - 0
4 100 && <=dBalance balance = balance - 100
5 1000 && > dBalance ERROR
Create the CCuentaTest class of the JUnit Test Case type in Eclipse that allows us to pass the white box unit tests of the ingresar method. The
You must have obtained the test cases in the first section of the exercise.
}
else
{
Debugging. Breakpoint. Only on entry 3
{
dSaldo = dSaldo + amount;
iCodErr = 0;
}
}
else {//author = ANTONIO MARTIN. Error shown if attempts are made to make more deposits
ERROR! No more than 3 entries can be made.
}
}
else
{
dSaldo = dSaldo - amount;
}
}
}
The corrected CcuentaTest code:
import [Link];
import [Link];
import [Link];
class CCuentaTest {
CCuenta myAccount = new CCuenta();
@ParameterizedTest
@CsvSource({"-10,1","0,2","10,0"})
Generate the following breakpoints to validate the behavior of the enter method in debug mode.
Breakpoint without condition when creating the miCuenta object in the main function. Line 3 of the main method code presented in the following.
page of this book.
Breakpoint at the return instruction of the ingresar method only if the amount to enter is less than 0. Line 20 of the ingresar method code.
which is presented later.
Breakpoint in the instruction where the balance is updated, it should only stop the third time it is updated. Line 16 of the code.
of the method to be introduced later.