Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

** Python ** ** THE PYTHON CODE IS PROVIDED ** Unit Testing open up the files shippingCost.py and test_shippingCost.py examine the code in shippingCost.py. It

** Python **

** THE PYTHON CODE IS PROVIDED **

Unit Testing

  • open up the files shippingCost.py and test_shippingCost.py
  • examine the code in shippingCost.py. It is a function consisting of an if/else if statement that returns the cost of shipping for a weight that is given as an argument to the function
  • examine the file test_ShippingCost.py. This is the file that will be used to define the test cases used to make sure that they function in file shippingCost is working as intended. Enter your test cases here as needed. Make sure that you cover each of the branches of the if statement in shippingCost.py
  • run the code from the command line in the same directory as your files are using the command python -m unittest test_shippingCost.py

Submit your completed file test_shippingCost.py (including documentation) and a screenshot of the output from the command line window after running the test.

files shippingCost.py

def calculateCost(weight): # Calculate the shipping charge. if weight > 10: shippingCost = 4.75 elif weight > 6: shippingCost = 4.00 elif weight > 2: shippingCost = 3.00 else: shippingCost = 1.50 return shippingCost

test_shippingCost.py

import unittest import shippingCost

class TestShippingCost(unittest.TestCase): #first test case def test_shippingCostA(self): result = shippingCost.calculateCost(11) self.assertEqual(result, 4.75)

#ENTER MORE TEST CASES HERE. EACH TEST CASE NEEDS TO HAVE A DIFFERENT NAME #check for failure #run with python -m unittest test_shippingCost.py

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

Combinatorial Testing In Cloud Computing

Authors: Wei-Tek Tsai ,Guanqiu Qi

1st Edition

9811044805, 978-9811044809

More Books

Students also viewed these Programming questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago