hzycaicai2012 / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Cannot Run robotium tests after save #663

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.create, save and finish test
2.right click on test and click run
3.fail

What is the expected output? What do you see instead?
my test class runs

What version of the product are you using? On what operating system?
robotium-solo-5.3.2-SNAPSHOT.jar

Please provide any additional information below.
At first i was getting file duplication errors so i added the following to my 
gradle build

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

Now im getting the following error 

Running tests
Test running startedTest running failed: Instrumentation run failed due to 
'java.lang.RuntimeException'
Empty test suite.

Original issue reported on code.google.com by liam.j.d...@gmail.com on 26 Feb 2015 at 6:20

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. What file duplication errors did you get? 

Original comment by renasr...@gmail.com on 26 Feb 2015 at 6:25

GoogleCodeExporter commented 9 years ago
* What went wrong:
Execution failed for task ':app:packageRcsi_wrapperDebugTest'.
> Duplicate files copied in APK META-INF/LICENSE.txt
    File 1: /home/liamduffy/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.3/fd32786786e2adb664d5ecc965da47629dca14ba/commons-codec-1.3.jar
    File 2: /home/liamduffy/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.3/fd32786786e2adb664d5ecc965da47629dca14ba/commons-codec-1.3.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug 
option to get more log output.

Original comment by liam.j.d...@gmail.com on 27 Feb 2015 at 9:48

GoogleCodeExporter commented 9 years ago
update. the test is saved into the generated AndroidTest folder, but i set the 
androidTestRoot in build.gradle to the following.    

sourceSets {
        androidTest.setRoot('src/test')
    }

and i move the test into that folder, delete the generated androidTest folder 
and correct the references to the android R file.

Still get the duplication error after that. 

when i add the following code to build.gradle the error disappears
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

when i run the tests then, the following error appears.
junit.framework.AssertionFailedError: Exception in constructor: testRun 
(java.lang.NoClassDefFoundError: 
com.maithu.medicapp.institution_group_activity.InstitutionGroupActivity
at com.maithu.medicapp.test.RobotiumTest.<init>(RobotiumTest.java:13)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:118)
at android.test.AndroidTestRunner.getTest(AndroidTestRunner.java:149)
at android.test.AndroidTestRunner.setTestClassName(AndroidTestRunner.java:57)
at 
android.test.suitebuilder.TestSuiteBuilder.addTestClassByName(TestSuiteBuilder.j
ava:80)
at 
android.test.InstrumentationTestRunner.parseTestClass(InstrumentationTestRunner.
java:443)
at 
android.test.InstrumentationTestRunner.parseTestClasses(InstrumentationTestRunne
r.java:424)
at 
android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:3
70)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4721)
at android.app.ActivityThread.access$1600(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:55
4)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1729)

Original comment by liam.j.d...@gmail.com on 27 Feb 2015 at 12:07

GoogleCodeExporter commented 9 years ago
I kind of figured it out. 

Im also running robolectric and have the following dependencies in my 
build.gradle file

dependencies {
    androidTestCompile 'junit:junit:4.11'
    androidTestCompile ('com.jayway.android.robotium:robotium-solo:5.0.1')
    androidTestCompile ('org.robolectric:robolectric:2.4') {
        exclude group: 'commons-logging', module: 'commons-logging'
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    androidTestCompile 'com.squareup:fest-android:1.0.8'

    compile 'com.splunk.mint:mint:3.5'
    compile 'com.google.code.gson:gson:2.3'
    compile 'org.jsoup:jsoup:1.8.1'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.8.6'
    compile 'com.google.android.gms:play-services-base:6.5.87'
}

I needed to add an exclude  to com.squareup:fest-android:1.0.8 to remove the 
noClassDefFound error like so.

androidTestCompile('com.squareup:fest-android:1.0.8') {
    exclude module: 'support-v4'
}

Now my tests run. 

But i still need the following lines:

   packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

no idea why

Original comment by liam.j.d...@gmail.com on 27 Feb 2015 at 1:02

GoogleCodeExporter commented 9 years ago

Original comment by renasr...@gmail.com on 4 Mar 2015 at 5:54