public static void main(String[] args) {
TaxCalculatorTest test = new TaxCalculatorTest();
test.testUsingCar();
test.testUsingLunch();
test.printSummary();
}
private void testUsingCar() { header("Starting -- testUsingCar"); //Declare Car car; TaxCalculator calc; car = new Car("Toyota", "Corolla", "10000"); //Construct calc = new TaxCalculator(car, "0.05"); //Execute calc.calculate(); assertEquals("500.00", calc.getSalesTaxFormatted()); assertEquals("10500.00", calc.getAfterTaxPriceFormatted()); }
private void testUsingLunch() { header("Starting -- testUsingLunch"); //Declare Lunch lunch; TaxCalculator calc; lunch = new Lunch("All you can eat Tacos", "10"); //Construct calc = new TaxCalculator(lunch, "0.07"); //Execute calc.calculate(); //Test assertEquals("0.70", calc.getSalesTaxFormatted()); assertEquals("10.70", calc.getAfterTaxPriceFormatted()); }
package taxcalc.test; import taxcalc.model.TaxCalculator; import testutil.AbstractTest; public class TaxCalculatorTest extends AbstractTest { //-------------------------- //Main (Entry Point) public static void main(String[] args) { TaxCalculatorTest test = new TaxCalculatorTest(); test.testUsingCar(); test.testUsingLunch(); test.printSummary(); } //-------------------------- //Tests private void testUsingCar() { header("Starting -- testUsingCar"); //Declare Car car; TaxCalculator calc; car = new Car("Toyota", "Corolla", "10000"); //Construct calc = new TaxCalculator(car, "0.05"); //Execute calc.calculate(); assertEquals("500.00", calc.getSalesTaxFormatted()); assertEquals("10500.00", calc.getAfterTaxPriceFormatted()); } private void testUsingLunch() { header("Starting -- testUsingLunch"); //Declare Lunch lunch; TaxCalculator calc; lunch = new Lunch("All you can eat Tacos", "10"); //Construct calc = new TaxCalculator(lunch, "0.07"); //Execute calc.calculate(); //Test assertEquals("0.70", calc.getSalesTaxFormatted()); assertEquals("10.70", calc.getAfterTaxPriceFormatted()); } }