Android studio Robotium gradle

I'm struggling to get Robotium to work with the Android gradle platform, and I cannot find a way to run the test using the gradle CLI. I placed robotium.jar "robotium-solo-5.4.1.jar" in the libs folder, added as a library. In the src folder, I created another package androidTest-> java-> for a test source with the same name as the name of the application package-> Test.java "java" (inside "androidTest") - green.

UI: as usual, using the menu Android Studio Run - works.

Console

: in the terminal, enter the following command: gradlew connectedAndroidTest = does not work. I also tried the "gradlew test", the test results are generated in the build / test-report file, but they show that no tests were found.

I want to run a Robotium test with a gradle CLI without connecting a device because I want to run tests in an Android emulator in CircleCI.

Is there a problem in the build.gradle / test file or is there something I can't see?

I am very grateful for any help!

***** This is my build.gradle file

apply plugin: 'com.android.application' apply plugin: 'io.fabric' android { compileSdkVersion 22 buildToolsVersion "22.0.1" dexOptions { // jumboMode true javaMaxHeapSize "2g" } defaultConfig { applicationId 'net.example' minSdkVersion 14 targetSdkVersion 22 versionName '2.8.1' versionCode 2801 multiDexEnabled true } buildTypes { debug{ debuggable true jniDebuggable true } release { debuggable false jniDebuggable false minifyEnabled true proguardFiles 'proguard-coda.txt', 'proguard-rules.pro' } } productFlavors { } packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } lintOptions { disable 'MissingTranslation' } sourceSets { androidTest { java.srcDirs = ['src/androidTest/java'] } } } dependencies { // Included library modules ... // My regular dependencies ... compile fileTree(include: ['*.jar'], dir: 'libs') // Test dependencies androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.4.1' androidTestCompile fileTree(dir: 'libs', include: 'robotium-solo-5.4.1.jar') } 

***** Robotium test file in the folder: app-> src-> androidTest-> java-> package name-> Test.java

 package net.example; import com.robotium.solo.*; import android.test.ActivityInstrumentationTestCase2; import android.view.View; import java.util.ArrayList; @SuppressWarnings("rawtypes") public class Test extends ActivityInstrumentationTestCase2 { private Solo solo; //Debug Logcat Tag for filtering private static final String TAG = "RoboDebug"; private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME ="net.example.exampleActivity"; private static Class<?> launcherActivityClass; static{ try { launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } @SuppressWarnings("unchecked") public Test() throws ClassNotFoundException { super(launcherActivityClass); } public void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation()); getActivity(); } @Override public void tearDown() throws Exception { solo.finishOpenedActivities(); super.tearDown(); } public void testRun() { //Wait for activity: 'net.example.exampleActivity' solo.waitForActivity("exampleActivity", 5000); //Wait for activity: 'coda.RootActivity' //!!!!!!!! assertTrue("RootActivity is not found!", solo.waitForActivity("RootActivity")); //Set default small timeout to 60000 milliseconds //Click on Beauty solo.clickOnText(java.util.regex.Pattern.quote("Beauty")); ArrayList<View> dig = solo.getViews(); android.util.Log.d(TAG, "Dig is: " + dig); } } 
+5
source share

All Articles