# JankTestBase

Summary:[Ctors](https://developer.android.com/reference/android/support/test/jank/JankTestBase#pubctors)\|[Methods](https://developer.android.com/reference/android/support/test/jank/JankTestBase#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/test/jank/JankTestBase#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/jank/JankTestBase#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/jank/JankTestBase#)  

# JankTestBase

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
JankTestBase
`  
`


``


``


``

extends `[InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase.html)`


``


`

|---|---|---|---|----------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||||
| ↳ | [junit.framework.Assert](https://developer.android.com/reference/junit/framework/Assert.html) ||||
|   | ↳ | [junit.framework.TestCase](https://developer.android.com/reference/junit/framework/TestCase.html) |||
|   |   | ↳ | [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase.html) ||
|   |   |   | ↳ | android.support.test.jank.JankTestBase |

<br />

*** ** * ** ***

Base test class for measuring Jank. This test class automatically monitors jank while executing each test method. Each test method is executed several times in a loop, according to the 'iterations' command line parameter. To perform additional setup / tear down steps for each iteration, subclasses can optionally override[beforeLoop()](https://developer.android.com/reference/android/support/test/jank/JankTestBase#beforeLoop())and[afterLoop()](https://developer.android.com/reference/android/support/test/jank/JankTestBase#afterLoop())methods. Test methods must be configured with the[JankTest](https://developer.android.com/reference/android/support/test/jank/JankTest)annotation. At minimum, the type of jank to measure and the number of expected frames must be specified.

## Summary

|                                                 ### Public constructors                                                  ||
|-----------------------------------------------------------------------------------------------------------------------|---|
| ` `[JankTestBase](https://developer.android.com/reference/android/support/test/jank/JankTestBase#JankTestBase())`() ` |

|                                                                                                                                ### Public methods                                                                                                                                 ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`      | ` `[afterLoop](https://developer.android.com/reference/android/support/test/jank/JankTestBase#afterLoop())`() ` Called after each iteration of the test method.                                                                                                     |
| ` void`      | ` `[afterTest](https://developer.android.com/reference/android/support/test/jank/JankTestBase#afterTest(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` metrics) ` Called once after all iterations have completed. |
| ` void`      | ` `[beforeLoop](https://developer.android.com/reference/android/support/test/jank/JankTestBase#beforeLoop())`() ` Called before each iteration of the test method.                                                                                                  |
| ` void`      | ` `[beforeTest](https://developer.android.com/reference/android/support/test/jank/JankTestBase#beforeTest())`() ` Called once before executing a test method.                                                                                                       |
| ` final int` | ` `[getCurrentIteration](https://developer.android.com/reference/android/support/test/jank/JankTestBase#getCurrentIteration())`() ` Return the index of the currently executing iteration.                                                                          |

|                                                                                                                                                       ### Protected methods                                                                                                                                                       ||
|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final `[Bundle](https://developer.android.com/reference/android/os/Bundle.html) | ` `[getArguments](https://developer.android.com/reference/android/support/test/jank/JankTestBase#getArguments())`() ` Returns a[Bundle](https://developer.android.com/reference/android/os/Bundle.html)containing the command line parameters. |
| ` void`                                                                           | ` `[runTest](https://developer.android.com/reference/android/support/test/jank/JankTestBase#runTest())`() ` <br />                                                                                                                             |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/jank/JankTestBase#)From class` `[android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase.html)` ` |--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Instrumentation](https://developer.android.com/reference/android/app/Instrumentation.html)         | ` getInstrumentation() `                                                                                                                                                                                                                                                            | | ` void`                                                                                                | ` injectInsrumentation(`[Instrumentation](https://developer.android.com/reference/android/app/Instrumentation.html)` arg0) `                                                                                                                                                        | | ` void`                                                                                                | ` injectInstrumentation(`[Instrumentation](https://developer.android.com/reference/android/app/Instrumentation.html)` arg0) `                                                                                                                                                       | | ` final <T extends `[Activity](https://developer.android.com/reference/android/app/Activity.html)`> T` | ` launchActivity(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Class](https://developer.android.com/reference/java/lang/Class.html)`<T> arg1, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` arg2) `                | | ` final <T extends `[Activity](https://developer.android.com/reference/android/app/Activity.html)`> T` | ` launchActivityWithIntent(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Class](https://developer.android.com/reference/java/lang/Class.html)`<T> arg1, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` arg2) ` | | ` void`                                                                                                | ` runTest() `                                                                                                                                                                                                                                                                       | | ` void`                                                                                                | ` runTestOnUiThread(`[Runnable](https://developer.android.com/reference/java/lang/Runnable.html)` arg0) `                                                                                                                                                                           | | ` void`                                                                                                | ` sendKeys(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0) `                                                                                                                                                                                        | | ` void`                                                                                                | ` sendKeys(int... arg0) `                                                                                                                                                                                                                                                           | | ` void`                                                                                                | ` sendRepeatedKeys(int... arg0) `                                                                                                                                                                                                                                                   | | ` void`                                                                                                | ` tearDown() `                                                                                                                                                                                                                                                                      | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/jank/JankTestBase#)From class` `[junit.framework.TestCase](https://developer.android.com/reference/junit/framework/TestCase.html)` ` |------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| | ` int`                                                                                   | ` countTestCases() `                                                                                  | | ` `[TestResult](https://developer.android.com/reference/junit/framework/TestResult.html) | ` createResult() `                                                                                    | | ` `[String](https://developer.android.com/reference/java/lang/String.html)               | ` getName() `                                                                                         | | ` `[TestResult](https://developer.android.com/reference/junit/framework/TestResult.html) | ` run() `                                                                                             | | ` void`                                                                                  | ` run(`[TestResult](https://developer.android.com/reference/junit/framework/TestResult.html)` arg0) ` | | ` void`                                                                                  | ` runBare() `                                                                                         | | ` void`                                                                                  | ` runTest() `                                                                                         | | ` void`                                                                                  | ` setName(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0) `           | | ` void`                                                                                  | ` setUp() `                                                                                           | | ` void`                                                                                  | ` tearDown() `                                                                                        | | ` `[String](https://developer.android.com/reference/java/lang/String.html)               | ` toString() `                                                                                        | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/jank/JankTestBase#)From class` `[junit.framework.Assert](https://developer.android.com/reference/junit/framework/Assert.html)` ` |-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` static void`                                                                    | ` assertEquals(boolean arg0, boolean arg1) `                                                                                                                                                                                                                      | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, long arg1, long arg2) `                                                                                                                                            | | ` static void`                                                                    | ` assertEquals(short arg0, short arg1) `                                                                                                                                                                                                                          | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[String](https://developer.android.com/reference/java/lang/String.html)` arg1, `[String](https://developer.android.com/reference/java/lang/String.html)` arg2) `  | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, int arg1, int arg2) `                                                                                                                                              | | ` static void`                                                                    | ` assertEquals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1) `                                                                                  | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, boolean arg1, boolean arg2) `                                                                                                                                      | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[String](https://developer.android.com/reference/java/lang/String.html)` arg1) `                                                                                  | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, short arg1, short arg2) `                                                                                                                                          | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg2) `  | | ` static void`                                                                    | ` assertEquals(char arg0, char arg1) `                                                                                                                                                                                                                            | | ` static void`                                                                    | ` assertEquals(byte arg0, byte arg1) `                                                                                                                                                                                                                            | | ` static void`                                                                    | ` assertEquals(double arg0, double arg1, double arg2) `                                                                                                                                                                                                           | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, char arg1, char arg2) `                                                                                                                                            | | ` static void`                                                                    | ` assertEquals(float arg0, float arg1, float arg2) `                                                                                                                                                                                                              | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, double arg1, double arg2, double arg3) `                                                                                                                           | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, byte arg1, byte arg2) `                                                                                                                                            | | ` static void`                                                                    | ` assertEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, float arg1, float arg2, float arg3) `                                                                                                                              | | ` static void`                                                                    | ` assertEquals(long arg0, long arg1) `                                                                                                                                                                                                                            | | ` static void`                                                                    | ` assertEquals(int arg0, int arg1) `                                                                                                                                                                                                                              | | ` static void`                                                                    | ` assertFalse(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, boolean arg1) `                                                                                                                                                     | | ` static void`                                                                    | ` assertFalse(boolean arg0) `                                                                                                                                                                                                                                     | | ` static void`                                                                    | ` assertNotNull(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) `                                                                                                                                                                 | | ` static void`                                                                    | ` assertNotNull(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1) `                                                                                 | | ` static void`                                                                    | ` assertNotSame(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg2) ` | | ` static void`                                                                    | ` assertNotSame(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1) `                                                                                 | | ` static void`                                                                    | ` assertNull(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1) `                                                                                    | | ` static void`                                                                    | ` assertNull(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) `                                                                                                                                                                    | | ` static void`                                                                    | ` assertSame(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg2) `    | | ` static void`                                                                    | ` assertSame(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1) `                                                                                    | | ` static void`                                                                    | ` assertTrue(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, boolean arg1) `                                                                                                                                                      | | ` static void`                                                                    | ` assertTrue(boolean arg0) `                                                                                                                                                                                                                                      | | ` static void`                                                                    | ` fail(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0) `                                                                                                                                                                          | | ` static void`                                                                    | ` fail() `                                                                                                                                                                                                                                                        | | ` static void`                                                                    | ` failNotEquals(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg2) ` | | ` static void`                                                                    | ` failNotSame(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg2) `   | | ` static void`                                                                    | ` failSame(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0) `                                                                                                                                                                      | | ` static `[String](https://developer.android.com/reference/java/lang/String.html) | ` format(`[String](https://developer.android.com/reference/java/lang/String.html)` arg0, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg1, `[Object](https://developer.android.com/reference/java/lang/Object.html)` arg2) `        | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/jank/JankTestBase#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/jank/JankTestBase#)From interface` `[junit.framework.Test](https://developer.android.com/reference/junit/framework/Test.html)` ` |------------------|-------------------------------------------------------------------------------------------------------| | ` abstract int`  | ` countTestCases() `                                                                                  | | ` abstract void` | ` run(`[TestResult](https://developer.android.com/reference/junit/framework/TestResult.html)` arg0) ` | ||

## Public constructors

### JankTestBase

```
JankTestBase ()
```

<br />

<br />

## Public methods

### afterLoop

```
void afterLoop ()
```

Called after each iteration of the test method.

<br />

|                                      Throws                                      ||
|-------------------------------------------------------------------------------|---|
| [Exception](https://developer.android.com/reference/java/lang/Exception.html) |   |

### afterTest

```
void afterTest (Bundle metrics)
```

Called once after all iterations have completed.

Note: default implementation reports the aggregated jank metrics via[sendStatus(int, Bundle)](https://developer.android.com/reference/android/app/Instrumentation.html#sendStatus(int, android.os.Bundle))

<br />

|                                   Parameters                                   ||
|-----------|---------------------------------------------------------------------|
| `metrics` | `Bundle`: the aggregated jank metrics after looped execution <br /> |

### beforeLoop

```
void beforeLoop ()
```

Called before each iteration of the test method.

<br />

|                                      Throws                                      ||
|-------------------------------------------------------------------------------|---|
| [Exception](https://developer.android.com/reference/java/lang/Exception.html) |   |

### beforeTest

```
void beforeTest ()
```

Called once before executing a test method.

<br />

|                                      Throws                                      ||
|-------------------------------------------------------------------------------|---|
| [Exception](https://developer.android.com/reference/java/lang/Exception.html) |   |

### getCurrentIteration

```
int getCurrentIteration ()
```

Return the index of the currently executing iteration.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

## Protected methods

### getArguments

```
Bundle getArguments ()
```

Returns a[Bundle](https://developer.android.com/reference/android/os/Bundle.html)containing the command line parameters.

<br />

|                                     Returns                                      ||
|--------------------------------------------------------------------------|--------|
| [Bundle](https://developer.android.com/reference/android/os/Bundle.html) | <br /> |

### runTest

```
void runTest ()
```

<br />

<br />

|                                      Throws                                      ||
|-------------------------------------------------------------------------------|---|
| [Throwable](https://developer.android.com/reference/java/lang/Throwable.html) |   |

-

  ## Annotations

  - [GfxMonitor](https://developer.android.com/reference/android/support/test/jank/GfxMonitor)
  - [JankTest](https://developer.android.com/reference/android/support/test/jank/JankTest)
-

  ## Classes

  - [JankTestBase](https://developer.android.com/reference/android/support/test/jank/JankTestBase)