How to pass an argument to an AndroidTestCase?

前端 未结 3 2185
一向
一向 2020-12-31 18:09

I\'ve implemented an Instrumentation and an AndroidTestCase.

For my tests I need to connect to an external WIFI device. I want the testers to be able to specify an S

3条回答
  •  清歌不尽
    2020-12-31 18:47

    To expand on selalerer's answer, instrumentation test(s) can be started with arguments specified via Gradle:

    ./gradlew -Pandroid.testInstrumentationRunnerArguments.exampleArgument=hello connectedAndroidTest
    

    You can retrieve instrumentation arguments using:

    InstrumentationRegistry.getArguments().getString("exampleArgument") // returns "hello"
    

提交回复
热议问题