Ok I found the problem, the error occurs only when the activity extends 
FragmentActivity from the support library. The tests works well when the 
activity extends Activity.

It's an old problem of classpath conflict, I found a SO question on it [1], 
the fix is to exclude the support library from the test app.

>From the gradle pov, it means adding this :

configurations {
    androidTestCompile.exclude group: 'com.android.support', module: 
'support-v4'
}

[1] 
http://stackoverflow.com/questions/5561353/fragmentactivity-can-not-be-tested-via-activityinstrumentationtestcase2

Le mardi 13 mai 2014 11:38:38 UTC+2, Thomas Bruyelle a écrit :
>
> I don't understand the error I get when I run the connectedCheck task. 
>
> The error occurs during the connectedAndroidTest subtask :
>
> android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests > 
> testSuiteConstructionFailed[GT-I9505 - 4.4.2] FAILED
> java.lang.RuntimeException: Exception during suite construction
> at 
> android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238)
> :app:connectedAndroidTest FAILED
>
>
> FAILURE: Build failed with an exception.
>
>
>
> The complete stack trace tells me the test suite does not found the 
> activity in the tested appplication (the last lines)
>
> java.lang.RuntimeException: Exception during suite construction
> at 
> android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238)
> at java.lang.reflect.Method.invokeNative(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:554)
> at 
> android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)
> Caused by: java.lang.reflect.InvocationTargetException
> at java.lang.reflect.Constructor.constructNative(Native Method)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87)
> at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73)
> at 
> android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:262)
> at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:184)
> at 
> android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:379)
> at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4572)
> at android.app.ActivityThread.access$1600(ActivityThread.java:161)
> at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)
> at android.os.Handler.dispatchMessage(Handler.java:102)
> at android.os.Looper.loop(Looper.java:157)
> at android.app.ActivityThread.main(ActivityThread.java:5356)
> at java.lang.reflect.Method.invokeNative(Native Method)
> at 
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
> at dalvik.system.NativeStart.main(Native Method)
> Caused by: java.lang.NoClassDefFoundError: com.myapp.PlanningActivity
> at com.myapp.PlanningActivityTest.<init>(PlanningActivityTest.java:17)
> ... 18 more
>
>
> I'm using the last android plugin 0.10, gradle 1.12 and tools version 
> 19.0.3.
>
> My tests are located in src/androidTest and 
> extends ActivityInstrumentationTestCase2.
>
>
> Thanks in advance for the help
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adt-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to