this docx file

advertisement
Individual Test Cases for Program 4
Name __________________________________
Section ______________________
Fill in the empty spaces in the tables. Read the assignment description carefully.
Testing the main function
Description of case
Input
Entering a valid action
choice (1-8) (Example)
3, query field choice 1, query
target “abc”, pressed Enter (at
end of query)
You can assume 7 more
cases to test each menu
choice
Expected Output/Behavior
Choice, user inputs as needed
The query function is run, gives records
found on the screen then main menu is
displayed again
The function chosen runs, does its job and
displays results, main menu is displayed
again
Unit Testing
Load function
Description of case
Testing with load from an empty
file (Example)
Input = user input while
running
Filename that exists
Expected Output/Behavior
Creates an empty list, reports
“database loaded”, returns []
Save function
Description of case
Database list with 1 record in it
(Example)
Inputs = database list, user
input while running
[[‘CD covers’, ‘2014/11/08’, IN,
‘Shelf 5’]], mynewdb
Expected Output/Behavior
Produces a file named
mynewdb.db, with 1 record in it,
CD covers,2014/11/08,IN,Shelf 5
Tells the user file saved
Display Database function
Description
Database list which has
more than 1 record in it, not
showing record numbers
(Example)
Input = database list, shownumbers
flag
[[‘CD covers’, ‘2014/11/08’,IN, ‘Shelf
5’],[“Apple iPhone”,
“2012/04/04”,OUT,”Dr. John Jones”]],
False
Expected Output
Name Date Purchased Status Location
CD covers
2014/11/08 IN
Shelf 5
Apple iPhone 2012/04/04 OUT Dr. John Jones
Appropriately formatted with no line numbers
Sort_db
Description
Empty database list, user says
yes to sort? (Example)
Input = Database list, user
inputs while running
User inputs valid field number,
then A, then Y, then presses
Enter
Entering new item (get_new_entry)
Description
Input = Database list, user
inputs while running
Database list has > 1 record,
Entering valid field values,
user does save it (Example)
Query
Description
Database list with >1 record,
entering invalid field choice,
entering target value which
appears in 2 records (Example)
Input = Database list, user
inputs during running
User enters invalid field choice,
5, then valid field choice 3, then
target value “IN”, then presses
Enter
Expected Output = return value
and behavior
Asks for field number, asks for
Ascending or Descending, asks
for Want to sort?, database list is
still [], tell user it’s sorted, waits
for Enter key
Expected Output = return value
and behavior
Expected Output = return value
and behavior
Asks user for field choice, tells
user it is invalid choice, asks for
another choice, then asks for
target value, then displays the
two records which match, the
wait for Enter key
Change_status
Description
Database list with 1 record, user
record choice incorrect, user
input values have commas, user
says Y, then presses Enter
(Example)
Remove_data
Description
Database list with 1 record, user
record choice incorrect, user
says Y, then presses Enter
(Example)
Input = Database list, user
input during running
user record choice is 2, then 1,
then location is "my house,
upstairs", then answers Y, then
presses Enter
Expected Output = return value
and/or behavior
tell user that record choice is
invalid, ask for another, then
change the status of record from
IN to OUT, asks for location,
replaces commas with spaces in
user location input, ask user if
should save changes, puts
changed record in database list,
tells user that, then waits for
Enter key
Input = Database list, user
input during running
user record choice is 2, then 1,
then answers Y, then presses
Enter
Expected Output = return value
and/or behavior
tell user that record choice is
invalid, ask for another, then ask
user if should delete record, does
delete it from the list, tells user
that, then waits for Enter key
----------------------------------------------------------------------------------------------------------------------------- --------------Utility functions
These do not appear on the main menu but are useful. They are called by other functions.
get_menu_choice
Description
user enters valid choice
(Example)
get_field_choice
Description
user enters invalid choice
(Example)
Input = user input during
running
user enters 5
Expected Output = return value
and/or behavior
returns '5'
Input = user input during
running
user enters 5
Expected Output = return value
and/or behavior
tells user it is invalid, then asks
for another choice
find_min
Description
database list with 2 elements,
choice = 3 (Example)
verifyYN
Description
user gives invalid input
(Example)
displayRecord
Description
record that fits in column width
(Example)
Input = database list, user
input during running
user enters 4 for field choice
Expected Output = return value
and/or behavior
returns the location of the
element with the smallest value
in the [3] locations in the records
in the database list (that is, in the
last (fourth) fields of each record)
Input = prompt, user input
during running
“Ädd this record?", user enters p
Expected Output = return value
and/or behavior
tells user that is not an accepted
response, waits for another input
Input = parameters = record
and column width
column width = 22
Expected Output = return value
and/or behavior
all four record field values are
output on the same line, padded
with spaces to make each
column 22 spaces wide
Download