Glacier960 / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
0 stars 0 forks source link

Espresso is unable to run it's own unit tests #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. mvn package
2. adb install ./testapp/target/testapp.apk
3. adb install ./espresso/libtests/target/espresso-tests.apk
4. adb shell am instrument -w 
com.google.android.apps.common.testing.ui.espresso.tests/com.google.android.apps
.common.testing.testrunner.GoogleInstrumentationTestRunner

What is the expected output? What do you see instead?

I expect the tests to run. I see this instead:
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test:...
com.google.android.apps.common.testing.ui.espresso.AppNotIdleExceptionTest:INSTR
UMENTATION_RESULT: shortMsg=java.lang.IllegalAccessError
INSTRUMENTATION_RESULT: longMsg=java.lang.IllegalAccessError: Class ref in 
pre-verified class resolved to unexpected implementation
INSTRUMENTATION_CODE: 0

What version of the product are you using? On what operating system?

I'm using this rev on OS X 10.9.
https://code.google.com/p/android-test-kit/source/detail?r=b49a13f06e5e832fa4569
00345ba47cb739637f7

Please provide any additional information below.

The details are on the mailing list.
https://groups.google.com/forum/#!topic/android-test-kit-discuss/03NHPOZRdq4

Espresso's build scripts produce code that doesn't run which makes running the 
unit tests impossible.

Original issue reported on code.google.com by m...@bootstraponline.com on 23 Oct 2013 at 3:13

GoogleCodeExporter commented 9 years ago
Workaround:
adb shell setprop dalvik.vm.dexopt-flags v=n,o=v
adb shell stop installd
adb shell start installd

reinstall the packages / run the test and it should be fine.

Background:

When you execute am instrument ... the classpath from the test apk and app apk 
are combined. If duplicate class definitions exist (even if they are identical) 
you'll get this exception.

The above set of adb commands disable the optimization that causes it to be a 
problem. 

Full fix is to muck the build scripts to prevent duplicate class elements 
appearing in both the test apk and the app apk.

Original comment by thoma...@google.com on 5 Nov 2013 at 7:40

GoogleCodeExporter commented 9 years ago
@Stephan - do you think this falls under the issues you're tackling with 
gradlefication?

Original comment by thoma...@google.com on 5 Nov 2013 at 7:53

GoogleCodeExporter commented 9 years ago
Issue 10 has been merged into this issue.

Original comment by thoma...@google.com on 5 Nov 2013 at 11:25

GoogleCodeExporter commented 9 years ago
If you exclude Guava from the test APK, it seems to solve this particular 
problem, but some of the tests seem to fail. See attached patch.

[INFO]   Tests run: 165,  Failures: 4,  Errors: 2

Original comment by YogurtE...@gmail.com on 6 Nov 2013 at 3:28

Attachments:

GoogleCodeExporter commented 9 years ago
I ran it with the patch and it finally worked but my results on a Nexus 5 are a 
little different:
 Tests run: 165,  Failures: 4,  Errors: 1

Original comment by Stath...@gmail.com on 7 Jan 2014 at 11:46

GoogleCodeExporter commented 9 years ago
Please try again with the new release. We fixed the duplicate dependencies 
issue.

Original comment by vale...@google.com on 9 Jan 2014 at 7:20

GoogleCodeExporter commented 9 years ago
Thanks. It looks like this commit fixed the issue:

https://code.google.com/p/android-test-kit/source/detail?r=aaf0047dfd8543997d365
2b9d75a63ece95f18df#

Original comment by m...@bootstraponline.com on 9 Jan 2014 at 7:22