ExecuteAutomation

Distributed test execution in android with Spoon

In this post we will discuss one of the coolest and most useful testing behavior called distributed testing of application in Android. Well, many of readers like you have been asking this to me and this is the answer for your question, Spoon!!

Spoon

Android’s ever-expanding ecosystem of devices creates a unique challenge to testing applications. Spoon aims to simplify this task by distributing instrumentation test execution and displaying the results in a meaningful way. Spoon makes existing instrumentation tests more useful. Using the application APK and instrumentation APK, Spoon runs the tests on multiple devices simultaneously. Once all tests have completed, a static HTML summary is generated with detailed information about each device and test.

Spoon Components

Spoon has only two components which are basically JAR files you can download from here Spoon client library jar file need to be added in our AUT or Test project for taking screenshots, whereas runner is responsible for running the test in multiple devices.

Spoon Command to run the test

java -jar spoon-runner-1.1.10-jar-with-dependencies.jar \
    --apk Calculator.apk --test-apk calculatortest.apk

Html Report

The HTML report generated by spoon test runner will look something like this shown below

Figure 1: Initial Spoon Report

Figure 2: Detailed Report

Figure 3: Device Log

Here is the complete video for the above discussion Here the complete code of the above video
	@SmallTest
	public void testDialog() throws Exception {
		// Declare all the controls to perform operations
		Spoon.screenshot(solo.getCurrentActivity(), "initial_state");
		EditText txtVal1 = (EditText) solo.getView(R.id.edtno1);
		EditText txtVal2 = (EditText) solo.getView(R.id.edtno2);
		RadioButton rdbtnMul = (RadioButton) solo.getView(R.id.rdMul);
		TextView viewResult = (TextView) solo.getView(R.id.txtResult);

		// Enter Text in the control
		Spoon.screenshot(solo.getCurrentActivity(), "Before_text1");
		solo.enterText(txtVal1, "12");
		Spoon.screenshot(solo.getCurrentActivity(), "Before_text2");
		solo.enterText(txtVal2, "12");

		// check for the result
		Log.d(TAG, "Checking for the results");
		if (viewResult.getText().toString().equalsIgnoreCase("24"))
			Log.d(TAG, "ADD PASSED");
		else
			Log.d(TAG, "ADD FAILED");

		// Click multiply
		Spoon.screenshot(solo.getCurrentActivity(), "Before_MultiplyRadio");
		solo.clickOnView(rdbtnMul);
		Spoon.screenshot(solo.getCurrentActivity(), "After_MultiplyRadio");

		// Verify Multipy stuffs
		if (viewResult.getText().toString().equalsIgnoreCase("144"))
			Log.d(TAG, "MUL PASSED");
		else
			Log.d(TAG, "MUL FAILED");

		Spoon.screenshot(solo.getCurrentActivity(), "final_show");
	}
Thanks for reading the post and watching the video !!! Please leave your comments and let me know if there is anything I should update in this post. Thanks, Karthik KK