Question: c . Make sure there are no syntax errors then press the green Run button at the top of Eclipse. We see that one of
c Make sure there are no syntax errors then press the green Run button at the top of Eclipse. We see that one of our test passed and one failed. And in the Failure trace, we see the expected and the actual results.
f Fix the setProdPricedouble method of the Product class so it handles values less than zero as described by our rules. Think about if you are not setting the value to check, so You need need to figure out where to add the change. Tips: Constructor
g Make sure there are no syntax errors then press the green Run button at the top of Eclipse. Did both test pass this time?
h Commit your code to the GitHub repo.
This is the Junit test code v
package junittesting Jtorres
import static org.junst.Assert. ;
public class ProductTest
@Test
public void testpriceVar
Product prod new Product Dr Pepper", ;
double expected
double actual prod.getprodprice:
assertegualsexpected actual, ;
@test
public void testPriceVarForlessThanzero
Product prod new Product Dr Pepper", ;
double expested ;
double actual prodogetprodprice ;
asserteguals expected astual, O;
This is the main method v
cackgge JunittestingJtorres;
pubize ciass
q
private string prodName;
private double prodPrices
private int prodQty;
public ProductString prodName, double prodPriceconstructor
this prodName prodName;
this. prodPrice prodPrice ;
public Product no acgs constructor
public static void mainString args
Product new Product:
psetprodPrice ;
System.out.printinpgetProdPrice
public String getProdName
return prodNames
public void setprodNameString prodName
this.prodiame prodivames
public double getprodPrice
return prodprices
public void setprodpricedouble prodprice f
ifprodprice
thisoprodprice
else
this. prodPrice prodPrices
public int getiprodoty
return prodotys
public void setprodoty int prodety
this prodety prodetys
public string tostring
return this, getProdName "this.getProdPrice;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
