Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add extra test runner parameter in Android Studio 2.3 instrumented tests

In Android Studio 2.3 there is no field that allows user to setup additional test runner parameters in Edit configuration window for Android Instrumented Tests, however this option was present in 2.2.x version.

Is there any other way in new AS (except from running test manually from command line) to add extra runner parameters to espresso tests?

edit:

I've filled an issue on bug tracker:

https://code.google.com/p/android/issues/detail?id=231797&q=instrumentation&sort=-opened&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened

like image 928
Than Avatar asked Jan 02 '17 10:01

Than


People also ask

Why do you use AndroidJUnitRunner when running UI tests?

Stay organized with collections Save and categorize content based on your preferences. The AndroidJUnitRunner class is a JUnit test runner that lets you run instrumented JUnit 4 tests on Android devices, including those using the Espresso, UI Automator, and Compose testing frameworks.

What should you annotate your test class with in instrumented tests?

Create an Instrumented Unit Test Class To create an instrumented JUnit 4 test class, add the @RunWith(AndroidJUnit4. class) annotation at the beginning of your test class definition. You also need to specify the AndroidJUnitRunner class provided in the Android Testing Support Library as your default test runner.

What is instrumented test in Android?

Instrumented tests run on Android devices, whether physical or emulated. As such, they can take advantage of the Android framework APIs. Instrumented tests therefore provide more fidelity than local tests, though they run much more slowly.

How do I create a test folder in Android?

To add a testing source set for your build variant in Android Studio, follow these steps: In the Project window on the left, click the drop-down menu and select the Project view. Within the appropriate module folder, right-click the src folder and click New > Directory.


1 Answers

There is no way to do this via that window, because it no longer exists.

An alternative is to subclass the Test Runner, and pass params there. Here is an example using Robolectric: https://www.snip2code.com/Snippet/90320/An-extension-of-RobolectricTestRunner-th

like image 175
Faraz Avatar answered Sep 27 '22 21:09

Faraz