Quick Index
Overview


We'll look at a examples of smoke tests.

We'll use DynamicArray as our subject (testee).

The most important methods are the constructors. Without them there are no objects.

We'll assume that DynamicArray core methods include "size", "add", "get", and "remove".

Constructor Smoke Tests


Example 1 - Constructing
This is the most important smoke test.

If no exception occurs, that means at least we can construct objects. Because without objects, we would have unusable software.
public void smokeTest_construct() {
	DynamicArray<String> dynArray = DynamicArray.newEmpty();
}



Core Method Smoke Tests


The short methods below exercise core methods
public void smokeTest_size() {
	DynamicArray<String> dynArray = DynamicArray.newEmpty();
	printf("Size (expecting 0): %d%n", dynArray.size());
}

public void smokeTest_add() {
	DynamicArray<String> dynArray = DynamicArray.newEmpty();
	dynArray.add("asha@hello.com");
	printf("Size (expecting 1): %d%n", dynArray.size());
}

public void smokeTest_get() {
	DynamicArray<String> dynArray = DynamicArray.newEmpty();
	String email = "asha@hello.com";
	dynArray.add(email);
	printf("First Element (expecting [%s]): %s%n", email, dynArray.get(0));
}

public void smokeTest_removeIndex() {
	DynamicArray<String> dynArray = DynamicArray.newEmpty();
	for (int i=0; i<10; i++)
		dynArray.add("Asha" + i);
	for (int i=0; i<10; i++)
		dynArray.removeIndex(dynArray.size() - 1);
	printf("Size (expecting 0): %d%n", dynArray.size());
}


Load Smoke Tests


The purpose of load smoke tests is to apply some "load" (pressure) on the software.

It is suprising how generally easy it is to loads of any desire size (as shown below).

The second test below is extremely important. It uses "proper objects" (e.g. employees) rather than primitive-like values (e.g, strings, integers). Using proper objects can expose more bugs.
public void smokeTest_load() {
	DynamicArray<String> dynArray = DynamicArray.newEmpty();
	for (int i = 0; i < 1000; i++)
		dynArray.add("Asha" + i);
	for (int i = 0; i < 1000; i += 50)
		printf("Element at [%d]: %s%n", i, dynArray.get(i));
}

public void smokeTest_object_load() {
	DynamicArray<Employee> dynArray = DynamicArray.newEmpty();
	for (int i = 0; i < 5000; i++)
		dynArray.add(new Employee(i, "Name" + i));
	for (int i = 0; i < 5000; i += 250)
		printf("Element at index [%d]: %s%n", i, dynArray.get(i));
}