Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GoogleCodeExporter opened this issue Jun 4, 2015 · 7 comments
Closed

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

GoogleCodeExporter opened this issue Jun 4, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

@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

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Issue 10 has been merged into this issue.

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

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant