Quick Index
Code Explanation


Greetings, I am AssociationSmokeTest.

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).

NOTE -- It may seem silly doing a smoke test on simple code (like Association). This is practice for the more complex.

My superclass is Abstract Test.

Read more about me below.

  • Run the tests
  • Show the testing summary
	public static void main(String[] args)  {
		AssociationSmokeTest test = new AssociationSmokeTest();
		test.testConstruct();
		test.testAccessors();
		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
		Association<String, Integer> assoc;
		String key = "A";
		Integer value = 10;
		//Construct
		assoc = new Association<>(key, value);
		//Test
		assertNotEquals(null, assoc);
	}
A simple smoke test:
  • Construct an Association
  • Use the accessor methods
  • Make sure results are not null
	private void testAccessors()  {
		header("Starting -- testAccessors");
		//Declare
		Association<Integer, Employee> assoc;
		int id = 1;
		Employee emp = new Employee(id, "Kofi Kingston");
		//Construct
		assoc = new Association<>(id, emp);
		//Test
		assertNotEquals(null, assoc.getKey());
		assertNotEquals(null, assoc.getValue());
	}

Complete Source Code


Here is my code.

Have Fun.

Your friend,
AssociationSmokeTest

package assoc.test;

import java.util.Arrays;
import java.util.List;

import assoc.model.Association;
import testutil.AbstractTest;
import testutil.Employee;

public class AssociationSmokeTest extends AbstractTest {

	//--------------------------
	//Main (Entry Point)

	public static void main(String[] args) {
		AssociationSmokeTest test = new AssociationSmokeTest();
		test.testConstruct();
		test.testAccessors();
		test.printSummary();
	}

	//--------------------------
	//Tests

	private void testConstruct() {
		header("Starting -- testConstruct");
		//Declare
		Association<String, Integer> assoc;
		String key = "A";
		Integer value = 10;
		//Construct
		assoc = new Association<>(key, value);
		//Test
		assertNotEquals(null, assoc);
	}

	private void testAccessors() {
		header("Starting -- testAccessors");
		//Declare
		Association<Integer, Employee> assoc;
		int id = 1;
		Employee emp = new Employee(id, "Kofi Kingston");
		//Construct
		assoc = new Association<>(id, emp);
		//Test
		assertNotEquals(null, assoc.getKey());
		assertNotEquals(null, assoc.getValue());
	}


}