Quick Index
TaxCalculatorTest


Hello There, I am TaxCalculatorTest

My job is to construct TaxCalculator object instances and hammer on them.

I really do try to squeeze out bugs

"main" method -- the run entry point
I kicks off tests and then
request a test summary.

	public static void main(String[] args)  {
		TaxCalculatorTest test = new TaxCalculatorTest();
		test.testUsingCar();
		test.testUsingLunch();
		test.printSummary();
	}
Input:
$10000 auto
5% tax
Expected Results:
tax = 10000 * 0.05 = 500
10000 + 500 = 10500
	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());
	}
Input:
$10 lunch
7% tax
Expected Results:
tax = 10 * 0.07 = 0.70
10 + 0.70 = 10.70
	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());
	}

Complete Source Code


Here is all my code.

Have Fun.

Yours,
TaxCalculatorTest

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());
	}
	


	
}