5.3. Equivalence partitioning
5.3.1. Experimental Methodology
This section describes the experiment and the theory behind it. The experiment consisted of five stages: failure analysis, creating sets of test sets, tests run, and, finally, compare equivalence partitioning results with operational profile based testing. An illustrative diagram is shown in Figure 9.
Figure 7. Experimental Methodology [17]
1. Failure analysis
The selected software already had information about what kind of bugs exist in a program that could be detected during testing. Data on exact bugs was the main key for searching and studying these bugs and how they manifest themselves. Knowledge about the sort of bugs was necessary for any changes in the system and to create test cases. At the stage of failure analysis, the code was reviewed, bugs were studied and the report was written (what kind of bugs program have and how they occur, the sample test cases were also designed to identify these bugs.
2. Creation of test case sets
Before creating test case sets, we must first design test cases by using the equivalence parti-tioning is a two-step procedure: (1) identify equivalence classes, and (2) define the test cases [15]. To create a test case First, you need to study the requirements and correctly identify the input area of the program, which helps to determine the input and output variables.
Secondly, divide the input domain into different categories, wherein each category partici-pants will be grouped who have at least some relation to each other. Third, When the test cases from a category display the same behavior, we based on the expected behavior, divide the set of values of each variable into disjoint subsets that span the entire area. Fourthly, equivalence classes can be combined using the multidimensional decomposition partitioning approach [18]. Invalid equivalence classes are classes that contain a combination of input that cannot be generated during the test. Some equivalence classes are not feasible due to the restriction of the requirement. The step of creating a set of test cases comes after failure
analysis. Thus, failures, program code, test technique, and test cases themselves are involved in creating test case sets.
3. Test conduction
In order to conduct testing, we have used the JUnit framework in collaboration with the open-source repository of SIR. SIR allows testing the software with the allocated test suit.
The software that has been selected has several defined bugs. Based on the test suites that were prepared by the operational profiles based testing technique, we have tested the software
“Account”. After that, we repeat the testing, but already with the test cases that have been build by the equivalence partitioning testing technique.
We derived operational profiles after the investigation of the source code of each software.
Based on those operational profiles we generated test suits. Regarding the test suits based on equivalence partitioning, they have been generated manually based on their techniques.
Here are the steps how test conducted:
• deployed the software from SIR
• source-code was investigated
• based on the operational profile test suits were generated
• based on the manual script of equivalence partitioning technique we made the test suits
• mutation analysis and code coverage were conducted
• the testing based on generated test cases were conducted
In Table 11 we provide the order of functions in terms of criterion “Importance”. The list starts from the most important function then ends with the least important. The Table contains the function and its description.
Table 11 Importance
№ Part Descriptions 1 a Valid account
b This function should have consist of any of params double amount, string currency, double MaxOverdraw). Should not be null.
2 a Valid amount should be deposited
b This function deposited an amount to the account. Should not be below zero, or zero and char. Should not be null. The currency in the account should be the same.
3 a Get valid balance
b This function gets a valid balance of the account. Should not be char, but an integer. Should not be null.
4 a Withdraw a valid amount
b This function withdraws an amount. Should not be below zero or zero, higher than BalanceSum, and char. Should not be null.
5 a Transfer an amount to another account
b This function transfers the amount to another account. The transferred amount should not be below zero, zero, higher than the Balance. Should not be null.
Can not transfer money to itself. The amount of transferred money from first account should be removed. Another account should add this amount of money.
Accounts should have the same currency.
6 a Converter of currencies in the account
b This function converts the currency. Also, it should convert the amount of money in the account regarding the currency. Each currency should have the correct rate. Should not be zero or below zero, and char. Should not be null.
Table 11 7 a Withdraw all money from the account
b This function withdraws all money from the account. Should not be below zero, zero, null. The account should not be empty(has a negative balance).
After withdrawal, the balance should be zero. Should not be higher than the max limit of withdrawing. Currency should be the same.
8 a Set valid balance
b This function sets a balance to the account. Should not be char, but an integer.
Should not be null.
9 a Valid number to set max overdraw sum
b This function sets max overdrawn sum. The number should not be below zero or char. The only type of input data is an integer. Should not be null.
10 a Valid number to get max overdraw sum
b This function gets max overdrawn sum. The number should not be higher than the sum that settled in the previous function, should not be below zero or char.
Should not be null.
11 a Set valid currency
b This function sets the currency to the account. Should not be an integer, but the char. Should not be null.
12 a Get valid currency
b This function returns a currency that the account has. Should not be an integer, but char. Should not be null.
Table 11. Importance
In Table 12 we provide the order of functions in terms of criterion “Probability of occurrence”.
The list starts from the most usage function and ends with the least usage. The Table contains the function and its description.
Table 12 Probability of occurrence
№ Part Descriptions
1 a Valid amount should be deposited
b This function deposited an amount to the account. Should not be below zero, or zero and char. Should not be null. The currency in the account should be the same.
2 a Get valid balance
b This function gets a valid balance of the account. Should not be char, but an integer. Should not be null.
3 a Withdraw a valid amount
b This function withdraws an amount. Should not be below zero or zero, higher than BalanceSum, and char. Should not be null.
4 a Transfer an amount to another account
b This function transfers the amount to another account. The transferred amount should not be below zero, zero, higher than the Balance. Should not be null.
Can not transfer money to itself. The amount of transferred money from first account should be removed. Another account should add this amount of money.
Accounts should have the same currency.
5 a Converter of currencies in the account
b This function converts the currency. Also, it should convert the amount of money in the account regarding the currency. Each currency should have the correct rate. Should not be zero or below zero, and char. Should not be null.
6 a Withdraw all money from the account
Table 12 b This function withdraws all money from the account. Should not be below zero, zero, null. The account should not be empty(has a negative balance).
After withdrawal, the balance should be zero. Should not be higher than the max limit of withdrawing. Currency should be the same.
7 a Valid account
b This function should have consist of any of params double amount, string currency, double MaxOverdraw). Should not be null.
8 a Set valid balance
b This function sets a balance to the account. Should not be char, but an integer.
Should not be null.
9 a Valid number to set max overdraw sum
b This function sets max overdrawn sum. The number should not be below zero or char. The only type of input data is an integer. Should not be null.
10 a Valid number to get max overdraw sum
b This function gets max overdrawn sum. The number should not be higher than the sum that settled in the previous function, should not be below zero or char.
Should not be null.
11 a Set valid currency
b This function sets the currency to the account. Should not be an integer, but the char. Should not be null.
12 a Get valid currency
b This function returns a currency that the account has. Should not be an integer, but char. Should not be null.
Table 12. Probability of occurrence
In Table 13 we provide the list of functions that have been sorted by arithmetical mean of importance and probability of occurrence. The value of each measure might be found in the Tables 5 and 9.
Table 13 Importance/Probability of occurrence
№ Part Descriptions
1 a Valid amount should be deposited
b This function deposited an amount to the account. Should not be below zero, or zero and char. Should not be null. The currency in the account should be the same.
2 a Get valid balance
b This function gets a valid balance of the account. Should not be char, but an integer. Should not be null.
3 a Withdraw a valid amount
b This function withdraws an amount. Should not be below zero or zero, higher than BalanceSum, and char. Should not be null.
4 a Transfer an amount to another account
b This function transfers the amount to another account. The transferred amount should not be below zero, zero, higher than the Balance. Should not be null.
Can not transfer money to itself. The amount of transferred money from first account should be removed. Another account should add this amount of money.
Accounts should have the same currency.
5 a Valid account
b This function should have consist of any of params double amount, string currency, double MaxOverdraw). Should not be null.
6 a Converter of currencies in the account
Table 13 b This function converts the currency. Also, it should convert the amount of money in the account regarding the currency. Each currency should have the correct rate. Should not be zero or below zero, and char. Should not be null.
7 a Withdraw all money from the account
b This function withdraws all money from the account. Should not be below zero, zero, null. The account should not be empty(has a negative balance).
After withdrawal, the balance should be zero. Should not be higher than the max limit of withdrawing. Currency should be the same.
8 a Set valid balance
b This function sets a balance to the account. Should not be char, but an integer.
Should not be null.
9 a Valid number to set max overdraw sum
b This function sets max overdrawn sum. The number should not be below zero or char. The only type of input data is an integer. Should not be null.
10 a Valid number to get max overdraw sum
b This function gets max overdrawn sum. The number should not be higher than the sum that settled in the previous function, should not be below zero or char.
Should not be null.
11 a Set valid currency
b This function sets the currency to the account. Should not be an integer, but the char. Should not be null.
12 a Get valid currency
b This function returns a currency that the account has. Should not be an integer, but char. Should not be null.
Table 13. Importance/Probability of occurrence
In Table 14, we have made the test cases based on the Equivalence Partitioning technique, each function tested and evaluated the reliability of software, by finding the number of bugs. The number of bugs we found by this technique is provided in the results section.
Table 14 Test Cases based on Equivalence Partitioning
№ Part Descriptions
1 a Valid amount should be deposited
b This function deposited an amount to the account. Should not be below zero, or zero and char. Should not be null. The currency in the account should be the same.
Table 14 c Account MyAccount = new Account();
MyAccount.setBalance(200.0);
MyAccount.setCurrency(“SEK”);
MyAccount.deposit(100.0);
assertEquals(300.0, MyAccount.getBalance()); // checking the amount of balance after the deposit
Account MyAccount1 = new Account();
MyAccount1.setBalance(100.0);
MyAccount1.setCurrency(“EUR”);
MyAccount1.deposit(100.0);
assertEquals(100.0, MyAccount1.getBalance()); // the balance should be the same as it was before because currencies are different
Account MyAccount2 = new Account();
MyAccount2.setBalance(100.0);
MyAccount2.setCurrency(“EUR”);
MyAccount2.deposit(null);
assertEquals(100.0, MyAccount2.getBalance()); // the balance should be the same as it was before because the // value of amount of deposit is null 2 a Get valid balance
b This function gets a valid balance of the account. Should not be char, but an integer. Should not be null.
c myBankAccount.setBalance(27.0);
assertEquals(“The value of the account shall be 27”, 27.0, myBankAc-count.getBalance(), 0);
3 a Withdraw a valid amount
b This function withdraws an amount. Should not be below zero or zero, higher than BalanceSum, and char. Should not be null.
Table 14 c Account MyAccount = new Account();
Account MyAccount1 = new Account();
MyAccount1.setBalance(200.0);
MyAccount1.withdraw(250.0);
assertEquals(200, MyAccount1.getBalance(), “The balance should stay the same if amount of withdraw is greather than balance”); // the balance became negative
Account MyAccount2 = new Account();
MyAccount2.setMaxOverdrawn(200.0);
MyAccount2.setBalance(200.0);
MyAccount2.withdraw(200.0);
assertEquals(0, MyAccount2.getBalance(), “The balance should be zero if balance same as withdraw”); //
Account MyAccount3 = new Account();
MyAccount3.setMaxOverdrawn(150.0);
MyAccount3.setBalance(200.0);
MyAccount3.withdraw(null);
assertEquals(200.0, MyAccount3.getBalance(), “The balance should stay the same as it was before because the amount of withdrawn money is null”);
Account MyAccount4 = new Account();
MyAccount4.setBalance(null);
MyAccount4.withdraw(100.0);
assertEquals(null, MyAccount4.getBalance(), “The balance should be empty as it was before”);
4 a Transfer an amount to another account
b This function transfers the amount to another account. The transferred amount should not be below zero, zero, higher than the Balance. Should not be null.
Can not transfer money to itself. The amount of transferred money from first account should be removed. Another account should add this amount of money.
Accounts should have the same currency.
Table 14 c Account MyAccount9 = new Account();
MyAccount9.setBalance(200.0);
MyAccount9.setCurrency(“SEK”);
Account MyAccount8 = new Account();
MyAccount8.setBalance(200.0);
MyAccount8.setCurrency(“SEK”);
MyAccount8.TransferToAccount(MyAccount9);
assertEquals(400.0, MyAccount9.getBalance(), “The balance should not be changed becuase it is not allowed to transfer money to itself”);
assertEquals(0.0, MyAccount8.getBalance(), “Balance from the source account shoulbe be romoved as well”);
Account MyAccount2 = new Account();
MyAccount2.setBalance(200.0);
MyAccount2.setCurrency(“SEK”);
Account MyAccountEur = new Account();
MyAccountEur.setCurrency(“EUR”);
MyAccountEur.setBalance(50.0);
MyAccountEur.convertToCurrency(“SEK”, 10.0); // added converting the currency to SEK
MyAccountEur.TransferToAccount(MyAccount2);
assertEquals(700.0, MyAccount2.getBalance(), “The balance in account should be 700 SEK”); // here is the bug in account method that it sums balance with no checking the currency
assertEquals(“SEK”, MyAccountEur.getCurrency(), “The Accounts should have the same currency as SEK”); // here test case for checking currency of account
Account MyAccount4 = new Account();
MyAccount4.setCurrency(“SEK”);
MyAccount4.setBalance(50.0);
MyAccount4.TransferToAccount(null);
assertEquals(50.0, MyAccount4.getBalance(), “Balance should be the same as it was before, because the targetAccount is empty”);
Account MyAccount5 = new Account();
MyAccount5.setCurrency(null);
MyAccount5.setBalance(50.0);
MyAccount5.TransferToAccount(MyAccount2);
assertEquals(50.0, MyAccount5.getBalance(), “Balance should be the same as it was before, because the account who wants to transfer money has not a currency”);
5 a Converter of currencies in the account
b This function converts the currency. Also, it should convert the amount of money in the account regarding the currency. Each currency should have the correct rate. Should not be zero or below zero, and char. Should not be null.
Table 14 c Account MyAccount = new Account();
MyAccount.setCurrency(“SEK”);
MyAccount.setBalance(500.0);
MyAccount.convertToCurrency(“EUR”, 0.1);
assertEquals(“EUR”, MyAccount.getCurrency(), “The Currency should be EUR”); // assertEquals(50, MyAccount.getBalance()); //check the amount in account
assertEquals(50, MyAccount.getBalance(), “The balance should be 50”);
Account MyAccount1 = new Account();
MyAccount1.setCurrency(“SEK”);
MyAccount1.setBalance(100.0);
MyAccount1.convertToCurrency(“SEK”, 10.0); // so here is the bug of con-verting, if accounts have same currency // it is still converting and multiply to the rate
assertEquals(“SEK”, MyAccount1.getCurrency(), “Should have the same currency”);
assertEquals(100.0, MyAccount1.getBalance(), “The balance should stay the same as it was before convertings”);
Account MyAccount2 = new Account();
MyAccount2.setCurrency(“SEK”);
MyAccount2.setBalance(100.0);
MyAccount2.convertToCurrency(null, 10.0);
assertEquals(“SEK”, MyAccount2.getCurrency(), “Should have the same currency as it was before and it is not supposed to be multiplied to the rate”);
Account MyAccount3 = new Account();
MyAccount3.setCurrency(“SEK”);
MyAccount3.setBalance(100.0);
MyAccount3.convertToCurrency(“EUR”, 0.0);
assertEquals(“SEK”, MyAccount3.getCurrency(), “Should have the same currency as it was before and it is not supposed to be multiplied to the rate, because rate is empty”);
6 a Withdraw all money from the account
b This function withdraws all money from the account. Should not be below zero, zero, null. The account should not be empty(has a negative balance).
After withdrawal, the balance should be zero. Should not be higher than the max limit of withdrawing. Currency should be the same.
Table 14 c Account MyAccount4 = new Account();
MyAccount4.setMaxOverdrawn(100.0);
MyAccount4.setCurrency(“SEK”);
MyAccount4.setBalance(0.0);
MyAccount4.withdrawAll();
assertEquals(0.0, MyAccount4.getBalance(), “Balance should be zero”);
Account MyAccount = new Account();
MyAccount.setMaxOverdrawn(100.0);
MyAccount.setCurrency(“SEK”);
MyAccount.setBalance(-300.0);
MyAccount.withdrawAll(); // assertEquals(0, MyAccount.getBalance(), “The amount of withdrawn money should // be 0 because it is less than 0”);
assertEquals(-300, MyAccount.getBalance(), “The amount of balance should be stayed as it is, -300”);
Account MyAccount2 = new Account();
MyAccount2.setMaxOverdrawn(200.0);
MyAccount2.setCurrency(“EUR”);
MyAccount2.setBalance(100.0);
MyAccount2.withdrawAll();
assertEquals(0.0, MyAccount2.getBalance(), “It should be same as it was because withdraw is possible just with SEK currency”);
Account MyAccount3 = new Account();
MyAccount3.setMaxOverdrawn(200.0);
MyAccount3.setCurrency(“EUR”);
MyAccount3.setBalance(100.0);
MyAccount3.convertToCurrency(“SEK”, 10.0);
MyAccount3.withdrawAll();
assertEquals(0.0, MyAccount3.getBalance(), “Balance should be zero”);
7 a Valid account
b This function should have consist of any of params double amount, string currency, double MaxOverdraw). Should not be null.
c Account MyAccount = new Account();
MyAccount.setCurrency(“SEK”);
assertEquals(“SEK”, MyAccount.getCurrency(), “The currenct of account should be SEK”);
8 a Set valid balance
b This function sets a balance to the account. Should not be char, but an integer.
Should not be null.
c myBankAccount.setBalance(27.0);
assertEquals(“The value of the account shall be 27”, 27.0, myBankAc-count.getBalance(), 0);
9 a Valid number to set max overdraw sum
b This function sets max overdrawn sum. The number should not be below zero or char. The only type of input data is an integer. Should not be null.
c myBankAccount.setMaxOverdrawn(100.0);
assertEquals(“Max overdrawn should be 100”, 100.0, myBankAc-count.getMaxOverdrawn(), 0);
10 a Valid number to get max overdraw sum
b This function gets max overdrawn sum. The number should not be higher than the sum that settled in the previous function, should not be below zero or char.
Should not be null.
Table 14 c myBankAccount = new Account(100.0, “SEK”, 100.0);
assertEquals(“Max overdrawn should be 100”, 100.0, myBankAc-count.getMaxOverdrawn(), 0);
11 a Set valid currency
b This function sets the currency to the account. Should not be an integer, but the char. Should not be null.
c myBankAccount.setCurrency(“EUR”);
assertEquals(“EUR”, myBankAccount.getCurrency());
12 a Get valid currency
b This function returns a currency that the account has. Should not be an integer, but char. Should not be null.
c Account myBankAccount = new Account(100.0, “SEK”, 0.0);
assertEquals(“SEK”, myBankAccount.getCurrency());
Table 14. Test Cases based on Equivalence Partitioning
In Table 15, also provided the test cases based on equivalence partitioning, but the fundamental difference is the number of test cases to each function that has been made. As we described above, the order of functions sorted by the arithmetical mean of two main measures. So we add more test cases to the functions that are at the top of the list.
In Table 15, also provided the test cases based on equivalence partitioning, but the fundamental difference is the number of test cases to each function that has been made. As we described above, the order of functions sorted by the arithmetical mean of two main measures. So we add more test cases to the functions that are at the top of the list.