问题描述
有人可以帮助我了解testProguardFile的使用.可以说我在gradle构建文件中调试了buildType及其配置如下:
Can someone help me understand the use of testProguardFile. Lets say i have debug buildType and its configured like this in gradle build file:
// inside android block
debug {
shrinkResources true // removes unused graphics etc
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFile('test-proguard-rules.pro')
}
那我为什么还要提供另一个名为test-proguard-rules.pro的proguard规则文件进行测试?如果我理解正确,那么当我进行仪器测试时会生成一个单独的apk,但是如果我仅进行单元测试该怎么办?
then why am i supplying another proguard rules file called test-proguard-rules.pro for testing ? If i understand correctly, when i do instrumentation testing a separate apk is generated but what if i'm doing just unit test, is it also the case ?
我想做的是运行单元测试"(不是仪器测试),但是让单元测试apk使用我在项目构建设置中定义的proguard规则.
what i would like to be able to do is run "unit tests" (not instrumentation tests) but have the unit test apk use the proguard rules that i have defined in my project build settings.
推荐答案
现在我看到它是什么testProguadFile(某些proguard文件")为您的测试apk提供了一个proguard文件,以便在测试时使用.这使我们可以使用proguard文件测试我们的应用程序.运行测试时生成的测试apk将被proguard混淆,然后测试将运行.这是测试proguard可能在您的应用程序中创建的任何异常的好方法.
Now i see what it is testProguadFile ('some proguard file') gives your test apk a proguard file to use when testing. This allows us test our app using a proguard file. The test apk generated when you run a test will be obfuscated with proguard and then the test will run. This is a good way to test for any anomalies proguard could create in your app.
这篇关于Android-Gradle testProguardFile-与单元测试有关的目的是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!