CP4P Testing Activity Instructions
CP4P Testing Activity Instructions
CREATE TEST CASES TO ILLUSTRATE WHETHER THE PROGRAM WORKS AS A USER WOULD
REASONABLY EXPECT.
• Positive test cases should always pass
• Negative test cases should pass
o but may fail if the programmer did not do
▪ sufficient validation or
▪ made assumptions about the quantity or quality of input data
Experimentation with a program is usually done before documenting test cases especially in the
case of black box testing. Exhaustive testing need not be recorded.
Test cases illustrate:
Did the programmer interpret the program's "intended function" notes reasonably?
Is the user interface consistent in what it suggests the user should do versus what the user can do?
How does the UI take care of the user if they make a mistake?
What quality of test data should be used? Repeating sequences of values should never be used.
What data will verify the program generates correct output?
Using a typical length string, develop test case data and values for positions:
• verify the minimum edge condition: Positive case, 1=first position of string
• verify the maximum edge condition: Positive case, n=last position of string
• verify nominal behaviour: Positive case, minimum < nominal < maximum
• verify repeatability. Just because it works the first time does not necessarily mean it works
the next time. (Never assume a program function's initial state will [not] continue to be its
ongoing operational state.)
• verify beyond the minimum edge condition: Negative case, first position less 1, less 2
• verify beyond the maximum edge condition: Negative case, last position plus 1, plus 2
• Negative tests for unexpected input:
o What happens when an atypical length string is used? ( < minimum, > maximum )
o What happens if something other than the expected data type is input, e.g. a whole
number (integer) for the character position?
Does the interface accurately translate 1=first, 2=second, 3=third, … requested character positions
to the program's internal representation of the string? Based on your knowledge of C string
processing, what is the bug and how should the programmer correct it?
Does the program work accurately with different length strings? What is the minimum length
string? the maximum length?
Are there constraints on the type of inputs accepted? i.e. what works? What doesn't? What
happens if something other than a whole number is input for the character position?
What validation should the program perform to avoid input problems or incorrect output?
White Box testing of a Tic-Tack-Toe game (AKA noughts and crosses or Xs and Os)
See the code in WhiteBox-TTT.c (cpr101.ca) and compile it.
The program provides a playing grid and alternates turns between two players who make their
mark by entering a position number. There is logic to declare wins. Strategy is up to the players.
Considerations for White Box testing start with the same concerns and strategies as for Black Box
testing. See the slides in the lecture presentation for additional testing opportunities that seeing
the source code allows. The obvious opportunity is all lines of code can be examined for testing.
This program erroneously allows players to NOT follow the normal rules of this game!
What are the test cases to show how a player is permitted to misbehave to gain an advantage?
What are the test cases to show how a player may be disadvantaged by the program's logic?
The program identifies a win by traditional metrics and more. What are the test cases to show what
this game allows as a single win, multiple wins, and the game winning condition?
Knowing how scanf() interacts with the OS stdin buffer is the key to testing how one player can
control the other player's moves.