- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我现在一直在阅读所有帖子,此时我真的很挣扎。
我试图在我的 android 项目中使用 WireMock 来帮助进行测试。然而,Proguard 总有话要说。
我的 gradle 依赖文件是这样的:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// Fine Tuned Google Play Services
compile "com.google.android.gms:play-services-ads:${PLAY_SERVICES_VERSION}"
compile "com.google.android.gms:play-services-plus:${PLAY_SERVICES_VERSION}"
compile "com.google.android.gms:play-services-identity:${PLAY_SERVICES_VERSION}"
compile "com.google.android.gms:play-services-location:${PLAY_SERVICES_VERSION}"
// we need base for "Google Cloud Messaging"
compile "com.google.android.gms:play-services-base:${PLAY_SERVICES_VERSION}"
// Android Wear
compile "com.google.android.gms:play-services-wearable:${PLAY_SERVICES_VERSION}"
compile 'pl.tajchert:exceptionwear:0.1.2'
// Handheld application
compile 'de.greenrobot:greendao:1.3.7'
compile "com.android.support:support-v13:21.0.3"
compile "com.android.support:appcompat-v7:${SUPPORT_LIB_VERSION}"
compile "com.android.support:support-v4:${SUPPORT_LIB_VERSION}"
compile "com.android.support:support-annotations:${SUPPORT_LIB_VERSION}"
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup:otto:1.3.6'
compile 'com.github.johnkil.android-robototextview:robototextview:2.4.0'
compile 'com.mixpanel.android:mixpanel-android:4.5.3@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
transitive = true;
}
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile "com.hannesdorfmann.fragmentargs:annotation:${FRAGARGS_VERSION}"
apt "com.hannesdorfmann.fragmentargs:processor:${FRAGARGS_VERSION}"
compile 'com.sothree.slidinguppanel:library:3.0.0'
compile 'com.adjust.sdk:adjust-android:4.0.4'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-math3:3.5'
compile 'se.emilsjolander:stickylistheaders:2.6.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.afollestad:material-dialogs:0.7.5.1'
provided 'javax.annotation:jsr250-api:1.0' // to enable guava proguard
// only on debug
compile 'com.facebook.stetho:stetho:1.1.1'
compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
// Dagger related dependencies
compile 'com.google.dagger:dagger:2.0'
apt 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
// androidTest dependencies
androidTestCompile 'com.google.dagger:dagger:2.0'
androidTestApt 'com.google.dagger:dagger-compiler:2.0'
androidTestProvided 'org.glassfish:javax.annotation:10.0-b28'
androidTestCompile('org.mockito:mockito-core:1.10.19') {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
androidTestCompile('com.google.dexmaker:dexmaker-mockito:1.2') {
exclude group: 'org.mockito', module: 'mockito-core'
}
androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile 'com.squareup.spoon:spoon-client:1.1.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
androidTestCompile ('com.github.tomakehurst:wiremock:1.56:standalone') {
exclude group: 'org.json', module: 'json'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'commons-io', module: 'commons-io'
exclude group: 'commons-cli', module: 'commons-cli'
}
// Unit testing dependencies
testCompile 'junit:junit:4.12'
testCompile('org.mockito:mockito-core:1.10.19') {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
}
我的测试混淆文件是这样的:
# Proguard rules run against the test module (split since Gradle plugin v 1.1.0)
-dontobfuscate
-ignorewarnings
# Specific classes that common test libs warn about
-dontwarn java.beans.**
-dontwarn javax.lang.model.element.Modifier
-dontwarn org.apache.tools.ant.**
-dontwarn org.assertj.core.internal.cglib.asm.util.TraceClassVisitor
-dontwarn org.easymock.**
-dontwarn org.jmock.core.**
-dontwarn org.w3c.dom.bootstrap.**
-dontwarn sun.misc.Unsafe
-dontwarn sun.reflect.**
-dontwarn wiremock.**
-dontwarn org.mockito.**
-dontwarn org.custommonkey.**
-dontwarn android.test.**
-dontwarn com.jayway.**
-dontwarn android.support.test.**
-dontwarn org.skyscreamer.**
-dontwarn org.slf4j.**
-dontwarn com.github.tomakehurst.wiremock.http.ResponseDefinition
-dontwarn com.google.common.net.InternetDomainName
我的主要项目依赖:
+--- com.google.android.gms:play-services-ads:7.0.0
| +--- com.google.android.gms:play-services-base:7.0.0
| | \--- com.android.support:support-v4:22.0.0 -> 22.2.0
| | \--- com.android.support:support-annotations:22.2.0 -> 22.1.1
| \--- com.google.android.gms:play-services-analytics:7.0.0
| \--- com.google.android.gms:play-services-base:7.0.0 (*)
+--- com.google.android.gms:play-services-plus:7.0.0
| \--- com.google.android.gms:play-services-base:7.0.0 (*)
+--- com.google.android.gms:play-services-identity:7.0.0
| \--- com.google.android.gms:play-services-base:7.0.0 (*)
+--- com.google.android.gms:play-services-location:7.0.0
| +--- com.google.android.gms:play-services-base:7.0.0 (*)
| \--- com.google.android.gms:play-services-maps:7.0.0
| \--- com.google.android.gms:play-services-base:7.0.0 (*)
+--- com.google.android.gms:play-services-base:7.0.0 (*)
+--- com.google.android.gms:play-services-wearable:7.0.0
| \--- com.google.android.gms:play-services-base:7.0.0 (*)
+--- pl.tajchert:exceptionwear:0.1.2
+--- de.greenrobot:greendao:1.3.7
+--- com.android.support:support-v13:21.0.3
| \--- com.android.support:support-v4:21.0.3 -> 22.2.0 (*)
+--- com.android.support:appcompat-v7:22.1.1 -> 22.2.0
| \--- com.android.support:support-v4:22.2.0 (*)
+--- com.android.support:support-v4:22.1.1 -> 22.2.0 (*)
+--- com.android.support:support-annotations:22.1.1
+--- de.hdodenhof:circleimageview:1.2.2
+--- com.squareup.retrofit:retrofit:1.9.0
| \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.okhttp:okhttp-urlconnection:2.3.0
| \--- com.squareup.okhttp:okhttp:2.3.0
| \--- com.squareup.okio:okio:1.3.0
+--- com.squareup.okhttp:okhttp:2.3.0 (*)
+--- com.squareup.picasso:picasso:2.5.2
+--- com.squareup:otto:1.3.6
+--- com.github.johnkil.android-robototextview:robototextview:2.4.0
| \--- com.android.support:appcompat-v7:22.1.0 -> 22.2.0 (*)
+--- com.mixpanel.android:mixpanel-android:4.5.3
+--- com.crashlytics.sdk.android:crashlytics:2.2.3
| +--- com.crashlytics.sdk.android:answers:1.1.2
| | \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
| +--- io.fabric.sdk.android:fabric:1.3.0
| \--- com.crashlytics.sdk.android:beta:1.1.2
| \--- io.fabric.sdk.android:fabric:1.2.0 -> 1.3.0
+--- com.facebook.android:facebook-android-sdk:4.0.1
| +--- com.android.support:support-v4:[21,22) -> 22.2.0 (*)
| \--- com.parse.bolts:bolts-android:1.1.4
+--- com.hannesdorfmann.fragmentargs:annotation:2.1.0
+--- com.sothree.slidinguppanel:library:3.0.0
| +--- com.android.support:support-v4:19.1.0 -> 22.2.0 (*)
| \--- com.nineoldandroids:library:2.4.0
+--- com.adjust.sdk:adjust-android:4.0.4
+--- commons-io:commons-io:2.4
+--- org.apache.commons:commons-math3:3.5
+--- se.emilsjolander:stickylistheaders:2.6.0
+--- com.melnykov:floatingactionbutton:1.3.0
| +--- com.android.support:support-annotations:21.0.3 -> 22.1.1
| +--- com.android.support:recyclerview-v7:21.0.3 -> 22.2.0
| | +--- com.android.support:support-annotations:22.2.0 -> 22.1.1
| | \--- com.android.support:support-v4:22.2.0 (*)
| \--- com.nineoldandroids:library:2.4.0
+--- com.jakewharton:butterknife:6.1.0
+--- com.afollestad:material-dialogs:0.7.5.1
| +--- com.android.support:support-v4:22.2.0 (*)
| +--- com.android.support:appcompat-v7:22.2.0 (*)
| +--- com.android.support:recyclerview-v7:22.2.0 (*)
| \--- com.android.support:support-annotations:22.2.0 -> 22.1.1
+--- com.facebook.stetho:stetho:1.1.1
| +--- commons-cli:commons-cli:1.2
| \--- com.google.code.findbugs:jsr305:2.0.1
+--- com.facebook.stetho:stetho-okhttp:1.1.1
| +--- com.squareup.okhttp:okhttp:2.2.0 -> 2.3.0 (*)
| +--- com.facebook.stetho:stetho:1.1.1 (*)
| \--- com.google.code.findbugs:jsr305:2.0.1
+--- com.google.dagger:dagger:2.0
| \--- javax.inject:javax.inject:1
+--- :pullToRefresh:
+--- project :PhotoViewLib
| \--- com.android.support:support-v4:22.0.0 -> 22.2.0 (*)
+--- project :h19sharedsources
| +--- com.google.android.gms:play-services-wearable:6.+ -> 7.0.0 (*)
| \--- com.android.support:support-annotations:21.0.3 -> 22.1.1
+--- project :h19base
+--- javax.annotation:jsr250-api:1.0
\--- org.glassfish:javax.annotation:10.0-b28
我的测试项目依赖:
+--- com.google.dagger:dagger:2.0
| \--- javax.inject:javax.inject:1
+--- org.mockito:mockito-core:1.10.19
| \--- org.objenesis:objenesis:2.1
+--- com.google.dexmaker:dexmaker-mockito:1.2
| \--- com.google.dexmaker:dexmaker:1.2
+--- com.squareup.assertj:assertj-android:1.0.0
| \--- org.assertj:assertj-core:1.6.1
+--- com.squareup.spoon:spoon-client:1.1.2
+--- com.android.support.test.espresso:espresso-core:2.1
| +--- com.android.support.test:rules:0.2
| | \--- com.android.support.test:runner:0.2
| | +--- junit:junit-dep:4.10
| | | \--- org.hamcrest:hamcrest-core:1.1
| | +--- com.android.support.test:exposed-instrumentation-api-publish:0.2
| | \--- com.android.support:support-annotations:22.0.0 -> 22.1.1
| +--- com.squareup:javawriter:2.1.1
| +--- org.hamcrest:hamcrest-integration:1.1
| | \--- org.hamcrest:hamcrest-core:1.1
| +--- com.android.support.test.espresso:espresso-idling-resource:2.1
| +--- org.hamcrest:hamcrest-library:1.1
| | \--- org.hamcrest:hamcrest-core:1.1
| +--- javax.inject:javax.inject:1
| +--- com.google.code.findbugs:jsr305:2.0.1
| +--- com.android.support.test:runner:0.2 (*)
| +--- javax.annotation:javax.annotation-api:1.2
| \--- org.hamcrest:hamcrest-core:1.1
\--- com.github.tomakehurst:wiremock:1.56
+--- org.slf4j:slf4j-api:1.7.6
+--- xmlunit:xmlunit:1.5
+--- org.mortbay.jetty:jetty:6.1.26
| +--- org.mortbay.jetty:jetty-util:6.1.26
| \--- org.mortbay.jetty:servlet-api:2.5-20081211
+--- org.skyscreamer:jsonassert:1.2.3
+--- com.jayway.jsonpath:json-path:0.8.1
| +--- net.minidev:json-smart:1.1.1
| \--- commons-lang:commons-lang:2.6
+--- com.fasterxml.jackson.core:jackson-annotations:2.4.2
+--- com.fasterxml.jackson.core:jackson-core:2.4.2
+--- com.google.guava:guava:18.0
+--- net.sf.jopt-simple:jopt-simple:4.7
\--- com.fasterxml.jackson.core:jackson-databind:2.4.2
+--- com.fasterxml.jackson.core:jackson-annotations:2.4.0 -> 2.4.2
\--- com.fasterxml.jackson.core:jackson-core:2.4.2
我的错误输出:
Note: there were 149 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning:can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-lang-2.6.jar:META-INF/LICENSE.txt])
Warning:can't write resource [META-INF/maven/org.mortbay.jetty/jetty/pom.properties] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/maven/org.mortbay.jetty/jetty/pom.properties])
Warning:can't write resource [META-INF/maven/org.mortbay.jetty/jetty/pom.xml] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/maven/org.mortbay.jetty/jetty/pom.xml])
Warning:can't write resource [META-INF/maven/com.google.guava/guava/pom.properties] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/maven/com.google.guava/guava/pom.properties])
Warning:can't write resource [META-INF/maven/com.google.guava/guava/pom.xml] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/maven/com.google.guava/guava/pom.xml])
Warning:can't write resource [META-INF/LICENSE] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/LICENSE])
Warning:can't write resource [META-INF/NOTICE] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/NOTICE])
Warning:can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties])
Warning:can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml])
Warning:can't write resource [META-INF/services/com.fasterxml.jackson.core.JsonFactory] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/services/com.fasterxml.jackson.core.JsonFactory])
Warning:can't write resource [META-INF/LICENSE] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/LICENSE])
Warning:can't write resource [META-INF/NOTICE] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/NOTICE])
Warning:can't write resource [META-INF/LICENSE] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/LICENSE])
Warning:can't write resource [META-INF/NOTICE] (Duplicate zip entry [wiremock-1.56-standalone.jar:META-INF/NOTICE])
:app:proguardStagingDebugAndroidTest FAILED
Error:Execution failed for task ':app:proguardStagingDebugAndroidTest'.
> java.io.IOException: Can't write [/Users/fabiocarballo/h19-android/app/build/intermediates/classes-proguard/androidTest/staging/debug/classes.jar] (Can't read [/Users/fabiocarballo/.gradle/caches/modules-2/files-2.1/com.github.tomakehurst/wiremock/1.56/4f6c96ea684cfa6375bbd7d2c2e4c8a47ccf615d/wiremock-1.56-standalone.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [wiremock-1.56-standalone.jar:org/custommonkey/xmlunit/AbstractNodeTester.class]))
谢谢大家。非常欢迎任何帮助!
最佳答案
不要试图与 Wiremock 和 Android studio 较劲,而是将 wiremock 作为一个并行进程独立启动。
下载此代码库
https://github.com/nenick/android-gradle-template
从项目根目录运行 Scripts/run-tests.sh
然后运行您的项目。
每当您想自定义响应时,请尝试对 wiremock 的管理面板进行安静的调用
在 http://wiremock.org/running-standalone.html 中搜索单词“curl” ,从 expresso 或 robolectric 测试或正在运行的应用程序进行调用(通过 HttpClient 或 AndroidAnnotations REST)
您实际上可以从 gradle 启动 wiremock(假设在连接测试之前)
task startWire(type: Exec) {
commandLine 'sh', '..\\Scripts\\start-wiremock.sh','&'
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleDebugAndroidTest') {
task.dependsOn startWire
}
}
关于android - 无法使用 Proguard 在 Android 项目上设置 Wiremock(重复 Zip 条目错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30624913/
我想使用 HTTP 客户端测试我们的应用大量的数据。是否可以创建无限长或几千兆字节的长度使用 WireMock 输出而不分配字节数组或具有该大小的字符串? 据我所知ResponseDefinition
我正在尝试使用以下 stub 命中 WireMock,但似乎查询参数没有匹配。这是回应: Request
我正在尝试测试我的代码,该代码具有对 HTTP 服务器的底层 GET 调用。 我正在尝试使用 WireMock ,并基于“入门”我有以下代码: @Rule public WireMockRule wi
我是 wiremock 的新手,想创建永久的自定义 stub 。我能够通过运行独立的 wiremock 实例并使用 curl 命令发送发布请求来创建 stub 来创建 stub 。这工作正常,但只要我
我正在使用 wiremock-jre8-standalone-2.27.0 jar 来模拟 API。我的映射 json 看起来像: { "request": { "url": "/sam
我已经实现了一个带有示例 REST/HTTP 请求模拟的基本 WireMock。服务器代码实现如下。 使用此代码,当我从 Postman 发出 GET 请求(即 GET http://127.0.0.
我使用 asp.net core 2.0 + wiremock.net 开发了一个项目。目前,我只能处理“__admin/mappings”目录下的 json 文件。但是,我有几个 json 文件,因
我正在尝试使用 WireMock 创建动态模拟。我有一种情况,如果我指定 URL 如下: http://localhost:8089/api/account/abc@abc.com 那么我应该收到如下
我在wiremock中定义了一个https stub ,如下所示:- public class HttpsMockMain { public static void main(String[]
假设我有端点:/url?number="321"&name="TEST",但是当我们匹配一个与请求匹配的请求时,我们要如何忽略查询参数的顺序(忽略查询参数的顺序) 在这种情况下,如果在查询参数标签中传
我正在使用 wiremock 来模拟 http 服务器,我正在返回来自 json 文件的响应(使用 withBodyFile 方法)。 现在我想根据请求参数选择并返回响应json文件。对于下面的示例,
我看到有关于在以独立方式运行wiremock时启用详细日志记录的说明,网址为http://wiremock.org/running-standalone.html (请参阅--verbose)。 从
我有一个运行良好的模拟 stubFor(WireMock.get("/varela/offerszones?channel=123").willReturn(aResponse()
我尝试使用以下 json,但 wiremock 无法识别我的更改。我看了wiremock的文档,看到他们说:JSON相等匹配是基于JsonUnit的,因此支持占位符。我也尝试使用 JDK 8 和 JD
我正在尝试使用以下要求比较Soap UI和Wiremock的功能(对于我的项目中的大多数情况来说,这是很现实的)。 目标是为货币价格服务创建一个模拟。要求: 在以下位置可访问 mytesthost/p
在特定数量的先前响应之后,是否可以配置 wiremock 以在相同的 URL 和相同的请求上发送不同的响应? For example: 1st request -> 503 response 2nd
在大多数集成测试中,我使用 spring-boot-test(2.1.9.RELEASE) 和 spring-cloud-contract-wiremock(2.0.2.RELEASE)。该测试基于以
我想为以下 e2e 场景添加一个测试: 我的应用程序正在通过内部代理服务器向外部服务发出 Web 请求,代理服务器操作请求正文,将请求转发到目标主机并返回返回的响应。 比如说 我向 external.
在旧版本的 Wiremock 中,我们可以将 te queryString 附加到匹配的 url,如下所示: wireMockRule.stubFor(get(urlPathEqualTo("/res
我正在尝试使用 Wiremock 2.24.1 根据请求路径动态返回不同的主体文件,如果在本地找不到,我想调用外部资源(作为代理)。 我正在使用这个映射文件: { "priority": 1,
我是一名优秀的程序员,十分优秀!