LoginSignup
0
0

More than 5 years have passed since last update.

How to run specific instrumented test method coded by Espresso from command line

Last updated at Posted at 2019-03-10

What's this?

This is the sample command to run specific Android Instrument test case coded by Espresso against Android app.

How?

Assume this the test code stored under app/src/androidTest/java/com/hoget/testCases/.

sampletest.kt
package com.hoget.instrumenttest.testcases.accountTest

......
@RunWith(AndroidJUnit4::class)
class HogetAccountTest {

@Test
    fun LoginLogoutTest() {
        // test code in here
    }
}

To run LoginLogoutTest() method

$ ./gradlew connectedAndroidTest -P android.testInstrumentationRunnerArguments.class=com.hoget.instrumenttest.testcases.accountTest.HogetAccountTest#LoginLogoutTest;

or

$ ./gradlew connectedAndroidTest -P android.testInstrumentationRunnerArguments.class=com.hoget.instrumenttest.testcases.accountTest.HogetAccountTest.LoginLogoutTest;

So, the template for the command is like this:

$ ./gradlew connectedAndroidTest -P android.testInstrumentationRunnerArguments.class=<App's Test Package Name>.<Test Class Name>#<TestMethodName>;

To Run All of Espresso Test

Add --continue option for prevent stop the test by fail of the test.

$ ./gradlew connectedAndroidTest --continue 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0