21.1k views
5 votes
Please design tests that satisfy RACC for the program below. Please provide necessary steps of generating the tests.public String twoPred (int x, int y) { boolean z; if (x < y) z = true; else z = false; if (z && x+y == 10) return "A"; else return "B"; }

1 Answer

7 votes

To design tests that satisfy RACC (Range, Accuracy, Cardinality, and Time) for the given program, we need to consider various scenarios and values for the input variables x and y. Here are some example tests:

Test 1:

Input: x = 4, y = 6

Expected Output: "A"

Explanation: In this case, x is less than y, and the sum of x and y is 10. Therefore, the condition z && x+y == 10 is true, and the program returns "A".

Test 2:

Input: x = 7, y = 3

Expected Output: "B"

Explanation: Here, x is not less than y, so the condition z is false. Regardless of the second condition, the program will return "B" because the first condition is not satisfied.

Test 3:

Input: x = 5, y = 5

Expected Output: "B"

Explanation: In this scenario, x is not less than y, and the sum of x and y is 10. However, since the first condition is false, the program will return "B".

Test 4:

Input: x = 3, y = 9

Expected Output: "B"

Explanation: Similar to the previous case, x is not less than y, and the sum of x and y is 12. As the first condition is false, the program returns "B".

These tests cover different ranges of values for x and y, ensuring accuracy in evaluating the conditions and producing the correct output. Additionally, the tests consider both possible outcomes "A" and "B" to cover the cardinality of the program's return values. Finally, generating these tests should not consume a significant amount of time.


User Wouter Den Ouden
by
8.1k points