Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2: Unit testing activity In this part of the coursework, you are to develop a set of unit tests for one of the example

Part 2: Unit testing activity

In this part of the coursework, you are to develop a set of unit tests for one of the example programs you have seen in the course. The output of this part is some source code and a testing report.

Instructions

Select ONE of the unit test example programs you have seen in the course: snakestats, terriblefall or norestforthewiccad. We recommend that you select the one you feel most confident working on.

* Write a total of 9 tests, organised into three sets. * Each test set should target one functional element of the program (e.g. an API path, a statistical function or a physics simulation function). * Write the code that allows the program to pass your tests. * Explain your approach in each test set. What was your strategy here? * Capture screenshots or console logs of the code before and after it passed the tests, showing the output of the unit testing library. Shorten the output to the most important part, where it lists the number of tests passed and failed. * Write everything up in a report which you should save out to PDF format

Here is a checklist you can use to ensure you have completed all the tasks:

Done?

Marks

Select example program to test

0

Test set 1 target function name (e.g. /spells)

0

Test set 1 written explanation of strategy

1

Test set 1 test 1 coded, explained and run

0.5

Test set 1 test 2 coded, explained and run

0.5

Test set 1 test 3 coded, explained and run

0.5

Test set 2 target function name

0

Test set 2 written explanation of strategy

1

Test set 2 test 1 coded, explained and run

0.5

Test set 2 test 2 coded, explained and run

0.5

Test set 2 test 3 coded, explained and run

0.5

Test set 3 target function name

0

Test set 3 written explanation of strategy

1

Test set 3 test 1 coded, explained and run

0.5

Test set 3 test 2 coded, explained and run

0.5

Time for a new function - getMax
Now we are going to work on another statistical function - getMax. Start by writing a failing test:
def test_getMax(self):
theMax = snakestats.getMax([6,5,4,3,2,1])
self.assertEqual(theMax, 6)
Basic implementation of getMax
Now the minimal implementation to pass this test:
def getMax(vals):
return vals[0]
./pagebreak
Another failing test for getMax
def test_getMaxLast(self):
theMax = snakestats.getMax([6,5,4,3,2,7])
self.assertEqual(theMax, 7)
Now update the getMax implementation to pass this test.
def getMax(vals):
maxSeen = 0
for i in range(len(vals)):
if vals[i] > maxSeen:
maxSeen = vals[i]
return maxSeen

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

Step: 3

blur-text-image

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

Databases Theory And Applications 27th Australasian Database Conference Adc 20 Sydney Nsw September 28 29 20 Proceedings Lncs 9877

Authors: Muhammad Aamir Cheema ,Wenjie Zhang ,Lijun Chang

1st Edition

3319469215, 978-3319469218

More Books

Students also viewed these Databases questions

Question

(4) C (U + 2102), the set of complex numbers; and

Answered: 1 week ago

Question

My opinions/suggestions are valued.

Answered: 1 week ago