0

I want to automate the Robotium tests running on my Android application, however, I need to pass in parameters to my tests in order to allow them to run with that configuration.

I can start my tests from the command line as such:

adb shell am instrument -r -w -e PARAM PARAM_1,PARAM_2 com.company.product.application.test/android.support.test.runner.AndroidJUnitRunner

I grab these parameters as such in my code:

Bundle extras = InstrumentationRegistry.getArguments();
if (extras.containsKey("PARAM")) {
    this.param1= new ArrayList<>();
    this.param1= Arrays.asList(extras.getString("PARAM").split("\\s*,\\s*"));
}

I am intending to call the Device Farm API (https://docs.aws.amazon.com/devicefarm/latest/APIReference/Welcome.html) to run the tests, but I am struggling to find anywhere where I can declare my arguments/parameters. Or find a way of uploading them in a file somewhere in AWS for the Device farm to read from.

I have found some articles from 4-5 years ago claiming that passing launcher parameters was not supported but it was being looked into, in case some claim me lazy, but no one has responded to any questions there, or on the Amazon forums so I thought I would place the question here.

Can anyone help me with the above?

Jeffrom
  • 61
  • 5

1 Answers1

1

The tests are executed by Device Farm internally so there's no way to control the arguments that get sent to it when running, currently. However, it should be possible to include additional files which could hold that same info for the tests. Here are two ideas I have regarding this:

  1. The tests could use the extra data feature of Device Farm. The extra data zip file gets uploaded to the /sdcard on the device. Then the tests could get the information from the device itself. This is part of the schedule run API so the script running the tests can do this programmatically.

  2. There could be a file that's included in the test apk that's uploaded to Device Farm. I've done something similar with Java Appium tests but not with instumention. In theory it should work.

Other than that, I have not found other ways of including arguments or files for Device Farm.

Hth -James

jmp
  • 2,175
  • 2
  • 17
  • 16
  • Thanks, @jmp! didn't even know this was a thing. So it will unzip the file to the `/sdcard` of the device, and the tests just need to access the `external/file1.txt` via an external storage grab? Sounds good - I'll let you know how it goes :) – Jeffrom Jul 26 '18 at 09:03
  • Yup, here is an example from the sample app to get the extra data. https://github.com/aws-samples/aws-device-farm-sample-app-for-android/blob/master/app/src/main/java/com/amazonaws/devicefarm/android/referenceapp/Fragments/Tabs/SupplementalUploads/SupplementalUploads_ExtraDataFragment.java#L49 – jmp Jul 26 '18 at 10:36