...
Code Block | ||||
---|---|---|---|---|
| ||||
package com.greenspector.sample.BasicExample; import android.content.Context; import android.test.InstrumentationTestCase; import android.support.test.InstrumentationRegistry; import com.greenspector.probe.android.interfaces.Api; public class GreenspectorBasicExample extends InstrumentationTestCase { /** Package to measure **/ private static final String BASIC_SAMPLE_PACKAGE = "com.android.chrome"; /** Probe configuration **/ private static final String APPLICATION = "TestApplication"; private static final String VERSION = "1.0.2"; private static final String URL = "https://my-instance.greenspector.com/api"; private static final String PRIVATETOKEN = "123456789AZERTY"; private static final int TIMEOUT = 180; private static final int INTERVAL = 200; private static final boolean ONLINE = true; private Api gsptApi; public void testBasicExample() { gsptApi = new Api(); gsptApi.setUpMeasure(getInstrumentation().getTargetContext(), new String[]{BASIC_SAMPLE_PACKAGE}, null, APPLICATION, VERSION, URL, PRIVATETOKEN, TIMEOUT, INTERVAL, ONLINE); gsptApi.startMeasure(); try { Thread.sleep(10000); } catch (InterruptedException e) { gsptApi.stopMeasure("test_Idle_Failed"); return; } gsptApi.stopMeasure("test_Idle"); } } |
Usage with GREENSPECTOR Test Runnner or Power Test Cloud/Bench
...
The probe configuration is slightly different in the case you integrate GREENSPECTOR Meter Android API in your automated tests (UI Automator or Espresso for example) that you launch with the Test Runner or the Power Test Cloud/Bench/Cloud.
- Some fields will be directly handled by the Test Runner (or the Power Test Cloud/Bench/Cloud). You can leave empty string values for the following fields:
application
,version
,url
andprivateToken
. - Set
online
tofalse
because the Test Runner (or the Power Test Cloud/Bench/Cloud) will read the results on the device.
...