Quick Index
Code Explanation


Greetings, I am TaxCalculatorSmokeTest.

I am a smoke test.

The purpose of a smoke test is to make sure the code does not blow up (throw exceptions) immediately (upon use).
My superclass is Abstract Test.

Read more about me below.

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

	public static void main(String[] args)  {
		TaxCalculatorSmokeTest test = new TaxCalculatorSmokeTest();
		test.testConstruct();
		test.testCalculate();
		test.printSummary();
	}
A simple smoke test:
  • Construct an Association
  • Make sure the result is not null
We're just checking if the code blows up.
The helper method assertNotEquals is used.
	private void testConstruct()  {
		header("Starting -- testConstruct");
		//Declare
		Car car;
		TaxCalculator calc;
		car = new Car("Toyota", "Corolla", "10000");
		//Construct
		calc = new TaxCalculator(car, "0.05");
		//Test
		assertNotEquals(null, calc);
	}
A nice smoke test:
By simply sending "calculate" we'll be exercising a lot of code.
  • Construct a TaxCalculator
  • Send "calculate"
We're just checking to make sure the code does not blow up.
So if we "get through" the message send, we'll pass the test
	private void testCalculate()  {
		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
		//If we get here (did not hit exception) we pass
		assertTrue(true);
	}

Complete Source Code


Here is all my code.

Have Fun.

Yours,
TaxCalculatorSmokeTest

package taxcalc.test;

import taxcalc.model.TaxCalculator;
import testutil.AbstractTest;

public class TaxCalculatorSmokeTest extends AbstractTest {
	
	//--------------------------
	//Main (Entry Point)
	
	public static void main(String[] args) {
		TaxCalculatorSmokeTest test = new TaxCalculatorSmokeTest();
		test.testConstruct();
		test.testCalculate();
		test.printSummary();
	}

	//--------------------------
	//Tests
	
	private void testConstruct() {
		header("Starting -- testConstruct");
		//Declare
		Car car;
		TaxCalculator calc;
		car = new Car("Toyota", "Corolla", "10000");
		//Construct
		calc = new TaxCalculator(car, "0.05");
		//Test
		assertNotEquals(null, calc);
	}
	
	private void testCalculate() {
		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
		//If we get here (did not hit exception) we pass
		assertTrue(true);
	}
	


	
}