wiremock uiautomator

151 views
Skip to first unread message

João Prudêncio

unread,
Apr 20, 2016, 12:24:43 PM4/20/16
to wiremock-user

Hey I'm trying to setup a mock server in my ui automator test.


But I'm getting the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/client/HttpClientBuilder;
at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClient(HttpClientFactory.java:45)


Do you have any idea what the problem may be?

Tom Akehurst

unread,
Apr 25, 2016, 9:34:23 AM4/25/16
to wiremock-user
Have you tried the standalone JAR? This re-packages the Apache HTTP client, so you can avoid conflicts with other transitive dependencies.

Jason Atwood

unread,
Aug 9, 2016, 6:15:02 PM8/9/16
to wiremock-user
I tried this and immediately hit the dex method limit. I'm not sure how Sam got this working w/out needing standalone: https://github.com/handstandsam/AndroidHttpMockingExamples/blob/master/app/build.gradle

Sam Edwards

unread,
Aug 18, 2016, 9:58:32 PM8/18/16
to wiremock-user
If you include WireMock, you'll immediately hit the dex limit as there are a bunch of Apache libraries that come with it.  In the gradle file you linked to from my project, you need to enable multidexing to allow for it to run WireMock.

multiDexEnabled = true

I'm not sure if there is a way to ONLY enable multi-dexing for an androidTest compile, but if I understand correctly, if you have multi-dex enabled, but don't actually hit the dex limit, you'll still only use 1 dex file.  So, just monitor your method count and you should be okay to do it.

Using WireMock for our Espresso tests has been pretty awesome so far.  It has downsides (the dependencies), but worth it for the tests.  Read more about it here: http://handstandsam.com/2016/01/30/running-wiremock-on-android/

Cheers,
-Sam

Jason Atwood

unread,
Aug 19, 2016, 3:08:18 PM8/19/16
to Sam Edwards, wiremock-user
There isn't a way to only enable multi-dexing for androidTestCompile. But I like that idea: use multidex but keep app under limit so multidexing only happens on test apk.

--
You received this message because you are subscribed to a topic in the Google Groups "wiremock-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wiremock-user/GWjVBqZlc6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wiremock-use...@googlegroups.com.
To post to this group, send email to wiremo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/6a0cdfe5-b0cb-4344-8d73-f5114f1fc603%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Atwood

unread,
Apr 9, 2017, 9:52:15 PM4/9/17
to wiremock-user, ssaa...@gmail.com
Sam,
I'm finally coming back to this and I want to confirm something you said. You are running multidex on your app apk. By doing so it also multidexes your androidTest instrumentation test apk? This seems to contradict what's said here:


"Note: Use of multidex for creating a test APK is not currently supported."

Jason Atwood

unread,
Apr 9, 2017, 10:21:48 PM4/9/17
to wiremock-user, ssaa...@gmail.com
Holy crap. I just tested this and you're right!!!! I can start using Wiremock again.

 Man the documentation on developer.android.com needs to be updated to reflect this.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages