Answered step by step
Verified Expert Solution
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 SimpleStorehwzip
Answer the following questions using JUnit and EclEmma to achieve 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 and In case of invalid names, the function will throw
IllegalArgumentException.
setPrice: a valid price is a decimal value between and In case
of invalid prices, the function will throw IllegalArgumentException.
o In class Store.java, test the following function using conditiondecision
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 : shipping cost
total : shipping cost
total : shipping is free
o In class Store.java, test the following function using multiplecondition
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 if the
total price of cart is greater than and less than or equal to A
discount of is given if the total is over If the user is a new customer,
then she will receive an extra 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
Note: You are expected to achieve 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 Junit and eclipse studio.
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