Answered step by step
Verified Expert Solution
Link Copied!

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 1 through 4 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 well-organized with regard
to where each function is being tested.
Part 5 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
5 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 1(read_pokedata()): 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 2(find_continents()): The inputs to this function is a database of Pokemon information.
It is ok to use your read_pokedata() 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 3(pokemon_in_continent()): Again this function requires a database, and it is again ok
to use your read_pokedata() 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 4(count_types()): Again this function requires a database, and it is again ok to use your
read_pokedata() 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 a6q4.py, with code for testing ALL of the different functions. Its probably
best if this file IMPORTS the functions you are testing, i.e import YOURFILENAME as Q
All of the input files that you created to be used in your tests
Evaluation
8 marks (2 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions