Most visited

Recently visited

Added in API level 1
Deprecated since API level 24

AndroidTestRunner

public class AndroidTestRunner
extends BaseTestRunner

java.lang.Object
   ↳ junit.runner.BaseTestRunner
     ↳ android.test.AndroidTestRunner


此类在API级别24中已被弃用。
改为使用AndroidJUnitRunner 应使用Android Testing Support Library编写新的测试。

Summary

Inherited constants

From class junit.runner.BaseTestRunner

Public constructors

AndroidTestRunner()

Public methods

void addTestListener(TestListener testListener)
void clearTestListeners()
List<TestCase> getTestCases()
String getTestClassName()
TestResult getTestResult()
void runTest()
void runTest(TestResult testResult)
void setContext(Context context)
void setInstrumentaiton(Instrumentation instrumentation)

此方法在API级别5中已弃用。拼写错误, setInstrumentation(android.app.Instrumentation)改为使用setInstrumentation(android.app.Instrumentation)

void setInstrumentation(Instrumentation instrumentation)
void setTest(Test test)
void setTestClassName(String testClassName, String testMethodName)
void testEnded(String testName)
void testFailed(int status, Test test, Throwable t)
void testStarted(String testName)

Protected methods

TestResult createTestResult()
Class loadSuiteClass(String suiteClassName)

返回套件名称的加载类。

void runFailed(String message)

覆盖以定义如何处理测试套件的失败加载。

Inherited methods

From class junit.runner.BaseTestRunner
From class java.lang.Object
From interface junit.framework.TestListener

Public constructors

AndroidTestRunner

Added in API level 1
AndroidTestRunner ()

Public methods

addTestListener

Added in API level 1
void addTestListener (TestListener testListener)

Parameters
testListener TestListener

clearTestListeners

Added in API level 1
void clearTestListeners ()

getTestCases

Added in API level 1
List<TestCase> getTestCases ()

Returns
List<TestCase>

getTestClassName

Added in API level 1
String getTestClassName ()

Returns
String

getTestResult

Added in API level 1
TestResult getTestResult ()

Returns
TestResult

runTest

Added in API level 1
void runTest ()

runTest

Added in API level 1
void runTest (TestResult testResult)

Parameters
testResult TestResult

setContext

Added in API level 1
void setContext (Context context)

Parameters
context Context

setInstrumentaiton

Added in API level 1
void setInstrumentaiton (Instrumentation instrumentation)

此方法在API级别5中已被弃用。
拼写错误, setInstrumentation(android.app.Instrumentation)改为使用setInstrumentation(android.app.Instrumentation)

Parameters
instrumentation Instrumentation

setInstrumentation

Added in API level 5
void setInstrumentation (Instrumentation instrumentation)

Parameters
instrumentation Instrumentation

setTest

Added in API level 1
void setTest (Test test)

Parameters
test Test

setTestClassName

Added in API level 1
void setTestClassName (String testClassName, 
                String testMethodName)

Parameters
testClassName String
testMethodName String

testEnded

Added in API level 1
void testEnded (String testName)

Parameters
testName String

testFailed

Added in API level 1
void testFailed (int status, 
                Test test, 
                Throwable t)

Parameters
status int
test Test
t Throwable

testStarted

Added in API level 1
void testStarted (String testName)

Parameters
testName String

Protected methods

createTestResult

Added in API level 1
TestResult createTestResult ()

Returns
TestResult

loadSuiteClass

Added in API level 1
Class loadSuiteClass (String suiteClassName)

返回套件名称的加载类。

Parameters
suiteClassName String
Returns
Class
Throws
ClassNotFoundException

runFailed

Added in API level 1
void runFailed (String message)

覆盖以定义如何处理测试套件的失败加载。

Parameters
message String

Hooray!