FileDocCategorySizeDatePackage
RemoteAndroidTestRunnerTest.javaAPI DocAndroid 1.5 API8139Wed May 06 22:41:08 BST 2009com.android.ddmlib.testrunner

RemoteAndroidTestRunnerTest

public class RemoteAndroidTestRunnerTest extends TestCase
Tests RemoteAndroidTestRunner.

Fields Summary
private RemoteAndroidTestRunner
mRunner
private MockDevice
mMockDevice
private static final String
TEST_PACKAGE
private static final String
TEST_RUNNER
Constructors Summary
Methods Summary
private voidassertStringsEquals(java.lang.String str1, java.lang.String str2)
Assert two strings are equal ignoring whitespace.

        String strippedStr1 = str1.replaceAll(" ", "");
        String strippedStr2 = str2.replaceAll(" ", "");
        assertEquals(strippedStr1, strippedStr2);
    
protected voidsetUp()

see
junit.framework.TestCase#setUp()


           
    
         
        mMockDevice = new MockDevice();
        mRunner = new RemoteAndroidTestRunner(TEST_PACKAGE, TEST_RUNNER, mMockDevice);
    
public voidtestRun()
Test the basic case building of the instrumentation runner command with no arguments.

        mRunner.run(new EmptyListener());
        assertStringsEquals(String.format("am instrument -w -r %s/%s", TEST_PACKAGE, TEST_RUNNER),
                mMockDevice.getLastShellCommand());
    
public voidtestRunWithAddInstrumentationArg()
Test the building of the instrumentation runner command with extra argument added.

        final String extraArgName = "blah";
        final String extraArgValue = "blahValue";
        mRunner.addInstrumentationArg(extraArgName, extraArgValue);
        mRunner.run(new EmptyListener());
        assertStringsEquals(String.format("am instrument -w -r -e %s %s %s/%s", extraArgName, 
                extraArgValue, TEST_PACKAGE, TEST_RUNNER), mMockDevice.getLastShellCommand());
    
public voidtestRunWithLog()
Test the building of the instrumentation runner command with log set.

        mRunner.setLogOnly(true);
        mRunner.run(new EmptyListener());
        assertStringsEquals(String.format("am instrument -w -r -e log true %s/%s", TEST_PACKAGE,
                TEST_RUNNER), mMockDevice.getLastShellCommand());
    
public voidtestRunWithMethod()
Test the building of the instrumentation runner command with method set.

        final String className = "FooTest";
        final String testName = "fooTest";
        mRunner.setMethodName(className, testName);
        mRunner.run(new EmptyListener());
        assertStringsEquals(String.format("am instrument -w -r -e class %s#%s %s/%s", className,
                testName, TEST_PACKAGE, TEST_RUNNER), mMockDevice.getLastShellCommand());
    
public voidtestRunWithPackage()
Test the building of the instrumentation runner command with test package set.

        final String packageName = "foo.test";
        mRunner.setTestPackageName(packageName);
        mRunner.run(new EmptyListener());
        assertStringsEquals(String.format("am instrument -w -r -e package %s %s/%s", packageName,
                TEST_PACKAGE, TEST_RUNNER), mMockDevice.getLastShellCommand());