Quick Index
Code Explanation


Greetings, I am DataNodeSmokeTest.

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 DataNode). 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)  {
		DataNodeSmokeTest test = new DataNodeSmokeTest();
		test.testConstruct();
		test.testAccessors();
		test.printSummary();
	}
A simple smoke test:
  • Declare a DataNode using String for the generic type "T"
  • Construct a DataNode
  • Make sure the constructed object is not null
Note how we replace the place holder param "T" with a real type "String".
The helper method assertNotEquals is used.
	private void testConstruct()  {
		header("Starting -- testConstruct");
		//Declare
		DataNode<String> node;
		String realData = "Asha";
		//Construct
		node = new DataNode<>(realData);
		//Test
		assertNotEquals(null, node);
	}
A simple smoke test:
  • Construct a DataNode
  • Use the accessor method
  • Make sure result is not null
Note how we replace the place holder param "T" with a real type "Employee".

	private void testAccessors()  {
		header("Starting -- testAccessors");
		//Declare
		DataNode<Employee> node;
		Employee emp = new Employee(1, "Kofi Kingston");
		//Construct
		node = new DataNode<>(emp);
		//Test
		assertNotEquals(null, node.getData());
	}

Complete Source Code


Here is my code.

Have Fun.

Your friend,
DataNodeSmokeTest

package datanode.test;

import datanode.model.DataNode;
import testutil.AbstractTest;
import testutil.Employee;

public class DataNodeSmokeTest extends AbstractTest {

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

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

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

	private void testConstruct() {
		header("Starting -- testConstruct");
		//Declare
		DataNode<String> node;
		String realData = "Asha";
		//Construct
		node = new DataNode<>(realData);
		//Test
		assertNotEquals(null, node);
	}

	private void testAccessors() {
		header("Starting -- testAccessors");
		//Declare
		DataNode<Employee> node;
		Employee emp = new Employee(1, "Kofi Kingston");
		//Construct
		node = new DataNode<>(emp);
		//Test
		assertNotEquals(null, node.getData());
	}


}