Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this homework you will be given a simple store program, in which you can create products and add them to your cart, then calculate

In this homework you will be given a simple store program, in which you can
create products and add them to your cart, then calculate shipping cost, plus
discounts. Using Junit and EclEmma, you will need to perform Whitebox testing.
You need to do the following:
Install eclipse for java and EclEmma plugin, then import the provided code (SimpleStorehw3.zip).
Answer the following questions using JUnit and EclEmma to achieve 100% coverage:
o In class Product.java, test the following functions using Statement and Decision
coverage, knowing that:
setName: a valid name consists of alphabetical characters with lengths
between 1 and 10. In case of invalid names, the function will throw
IllegalArgumentException.
setPrice: a valid price is a decimal value between 0.01 and 1000. In case
of invalid prices, the function will throw IllegalArgumentException.
o In class Store.java, test the following function using condition-decision
coverage, knowing that:
computeShippingCost: This function calculates the shipping cost based
on the total price in cart. The function returns the following:
cart is empty: throw IllegalStateException
total <100: shipping cost 20
100<= total <500: shipping cost 10
total >=500: shipping is free
o In class Store.java, test the following function using multiple-condition
coverage, knowing that:
calculateDiscount: the function computes the total percentage of the
discount a user will get as follows: The user will get a discount of 5% if the
total price of cart is greater than 100 and less than or equal to 500. A
discount of 7% is given if the total is over 500. If the user is a new customer,
then she will receive an extra 10% discount. Noting that discounts can be added
up.
o In class Cart.java, test the following function using loop coverage, knowing that:
total: the function will compute the total cost of items in cart and return
the total as decimal value. In case the cart was empty the function will
return 0.
Note: You are expected to achieve 100% coverage in testing all the functions above. Your
code will be graded accordingly.
Submit your testcases in one test class on the elearning.
Important notes:
The Driver class demonstrates how to use Store Class.
Make sure to keep each testcase in a sperate test function.
If your code doesnt compile you will get zero.
Make sure to use Junit4 and eclipse studio.

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

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions