Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer the following questions using JUnit and EclEmma to achieve 1 0 0 % coverage: o In class Product.java, test the following functions using Statement

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. i need code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions