尝试在我的robotium android测试中启动WireMockServer时收到以下堆栈跟踪。 可能是Apache Http客户端的两个版本之间的冲突,但我还没有设法解决它。 有什么想法?在Android集成测试中使用WireMock时NoSuchMethodError
java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLSocketFactory.<init>
at com.github.tomakehurst.wiremock.http.HttpClientFactory.createSslSocketFactory(HttpClientFactory.java:110)
at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClientConnectionManagerWithSSLSettings(HttpClientFactory.java:88)
at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClient(HttpClientFactory.java:54)
at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClient(HttpClientFactory.java:70)
at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.<init>(ProxyResponseRenderer.java:58)
at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:96)
at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:140)
at com.me.expertsystem.AcceptanceTest.setUp(AcceptanceTest.java:63)
感谢萨姆在Wiremock支持Android的更新!之后我转向了mockwebserver,但是了解一个人也可以在Android环境中依赖Wiremock(我倾向于通过mockwebserver),这很有用。 – 2016-01-09 18:04:49
是的,我编写的示例项目(https://github.com/handstandsam/AndroidHttpMockingExamples)展示了两者,但WireMock功能更丰富。缺点是它确实伴随着Jetty等需求的大量依赖。但是,它们只需要包含在androidTestCompile中,而不是在您的发布APK中。另一个缺点是我必须启用multi-dex才能获得演示应用程序来运行它。但好处包括一把瑞士军刀,用于嘲笑和测试。 – 2016-01-10 03:38:52