Question: testing example public static int RewardPoints(double spentamount, double creditlimit) { int rewards = 0; if (spentamount else if (spentamount - creditlimit else if (spentamount -
testing example
public static int RewardPoints(double spentamount, double creditlimit) {
int rewards = 0;
if (spentamount
else if (spentamount - creditlimit
else if (spentamount - creditlimit >= 500) rewards = 3*(int)Math.round(spentamount - creditlimit);
else if (spentamount - creditlimit >= 300 && spentamount - spentamount
else if (spentamount - creditlimit >= 100 && spentamount - spentamount
return rewards;
}
testing example test
class TestingExampleTest {
@BeforeAll
static void setUpBeforeClass() {
TestingExample obj = new TestingExample();
}
@Test
void test1() {
assertEquals("The function should give 1800 points in this situation", 1800, TestingExample.RewardPoints(1100, 500));
}
@Test
void test4() {
assertEquals("The function should give 0 points in this situation", 0, TestingExample.RewardPoints(550, 500));
}
@Test
void test2() {
assertEquals("The function should give 1800 points in this situation", 1800, TestingExample.RewardPoints(1100, 500));
}
}
For this task, we are asking you to implement a comprehensive set of test cases for the given method in the enclosed example. The given code is a working code that solves the problem of calculating reward points that are given to credit card customers, who use their card exceeding their credit limit. Suppose customers are given reward points instead of added charges. The points are given according to the table below. Please note that the given code calculates the points only and do nothing about penalties. Your job is to write a set of Junit test cases that comprehensively test the given code. A comprehensive set of test cases is a set of tests that checks all the paths in the code. If there is a conditional statement, both the true and false condition should be tested. If there is a multiple condition, all possible combination of the conditions being true or false should be tested. This means if the condition is "A AND B", 4 different test cases should be written, unless it is not possible. The 4 conditions are: A= True, B= True A= True, B= False A= False, B= True A= False, B= False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
