Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Purpose: To practice testing the parts of a working program Write a test driver that includes tests for all of the functions from the previous
Purpose: To practice testing the parts of a working program
Write a test driver that includes tests for all of the functions from the previous Pokemon Locations question.
You should test each function for parts through independently. This means that for each function, you
must invent a variety of test inputs for which you can calculate the correct expected output by hand. You
can put all of these tests in the same python code file, but make sure this file is wellorganized with regard
to where each function is being tested.
Part of the Pokemon Locations question did not involve writing a separate function but instead simply
required calling the other functions in sequence. As such, you do not need to do any formal testing for Part
here. Thats part of the advantage of decomposing a problem into many reasonably small functions!
Below are some tips on creating your test cases for each of the four functions.
Testing Part readpokedata: Since this function reads data from a file, your test inputs must
in fact consist of different files! Thus, for each test, create an input file with the same format as
pokemonLocations.txt Your test files will likely be MUCH smaller than the provided file. Do not bother
testing with files that are not correctly formatted, focus instead on the diversity of possible valid files.
Testing Part findcontinents: The inputs to this function is a database of Pokemon information.
It is ok to use your readpokedata function to create the database rather than typing in database
literals so long as you confident that function works thanks to testing it in which case your test inputs
will again consist of input files. Careful! The pokemon in your database might be processed in any
order because its a dictionary! and we dont care about the ORDER of the continents in the resulting
list. You can deal with this by SORTING the resulting list before comparing it to the expected result!
Testing Part pokemonincontinent: Again this function requires a database, and it is again ok
to use your readpokedata funtion to create it if you find this less tedious. The continent name for
each test should however be picked manually. And again, youll want to sort the resulting list before
testing.
Testing Part counttypes: Again this function requires a database, and it is again ok to use your
readpokedata funtion to create it if you find this less tedious. The list of pokemon names should
however be created manually.
Note that it is possible to complete and get full marks for this question even if you did not complete or
even attempt the Pokemon Locations question.
What to Hand In
Your test driver in a SINGLE aqpy with code for testing ALL of the different functions. Its probably
best if this file IMPORTS the functions you are testing, ie import YOURFILENAME as Q
All of the input files that you created to be used in your tests
Evaluation
marks per function: Function is tested with a thoughtful and adequate number of tests
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started