FileDocCategorySizeDatePackage
UiAutomatorInstrumentationTestRunner.javaAPI DocAndroid 5.1 API2740Thu Mar 12 22:22:08 GMT 2015com.android.uiautomator.testrunner

UiAutomatorInstrumentationTestRunner

public class UiAutomatorInstrumentationTestRunner extends android.test.InstrumentationTestRunner
Test runner for {@link UiAutomatorTestCase}s. Such tests are executed on the device and have access to an applications context.

Fields Summary
Constructors Summary
Methods Summary
protected android.test.AndroidTestRunnergetAndroidTestRunner()

        AndroidTestRunner testRunner = super.getAndroidTestRunner();
        testRunner.addTestListener(new TestListener() {
            @Override
            public void startTest(Test test) {
                if (test instanceof UiAutomatorTestCase) {
                    ((UiAutomatorTestCase)test).initialize(getArguments());
                }
            }

            @Override
            public void endTest(Test test) {
            }

            @Override
            public void addFailure(Test test, AssertionFailedError e) {
            }

            @Override
            public void addError(Test test, Throwable t) {
            }
        });
        return testRunner;
    
public voidonStart()

        // process runner arguments before test starts
        String traceType = getArguments().getString("traceOutputMode");
        if(traceType != null) {
            Tracer.Mode mode = Tracer.Mode.valueOf(Tracer.Mode.class, traceType);
            if (mode == Tracer.Mode.FILE || mode == Tracer.Mode.ALL) {
                String filename = getArguments().getString("traceLogFilename");
                if (filename == null) {
                    throw new RuntimeException("Name of log file not specified. " +
                            "Please specify it using traceLogFilename parameter");
                }
                Tracer.getInstance().setOutputFilename(filename);
            }
            Tracer.getInstance().setOutputMode(mode);
        }
        super.onStart();