Author | Message |
---|---|
ly.c.christopher
Posts: 5
|
Posted 22:47 Jan 26, 2014 |
How would you use a JUnit test for this problem? Unlike the rectangle example posted by RABBOT this problem has much more calculations. rectangle example http://csns.calstatela.edu/department/cs/forum/topic/view?id=4618727 |
rabbott
Posts: 1649
|
Posted 23:42 Jan 26, 2014 |
Look at the problem again. Construct a JUnit test for the method that gives you the costOfOwnership over a period of time. You need not (and should not) design a JUnit test for the entire input-output program. JUnit tests are intended primarily to test individual methods. |
ly.c.christopher
Posts: 5
|
Posted 23:55 Jan 26, 2014 |
When I test the method i get this. Warning from last compilation assertEquals(double,double) in org.junit.Assert has been deprecated This is my test method : @Test This is the method I'm testing: public double ownershipCost(double carCost,double mpg , double resaleValue) double totalCarGas = carCost + costToDrive; //totals the cost of the car and gas spent constructor: private double gasPrices; Last edited by ly.c.christopher at
23:57 Jan 26, 2014.
|
rabbott
Posts: 1649
|
Posted 00:15 Jan 27, 2014 |
assert Equality( ) needs a third parameter when you are testing doubles. The 3rd parameter is the margin of error.
For this problem 0.001 should be fine as the margin of error. Last edited by rabbott at
09:22 Jan 27, 2014.
|
ly.c.christopher
Posts: 5
|
Posted 00:18 Jan 27, 2014 |
Thank you! |