Answered step by step
Verified Expert Solution
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 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. i need code
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