我有一个Android应用程序,我想对它进行单元测试。使用MVP模式,我能够在"android“之外提取许多类,以便在单独的module1中将它们作为普通的单元测试(使用Junit)进行测试。但是,我想记录一些来自这些类的消息。因此,我尝试在android绑定中使用slf4j-api。目的是为我的测试提供简单的约束。但是"test“模块首先抱怨类路径中有两个slf4j绑定,并且他正在使用android绑定。
因此,我的问题是,如何将slf4j-android依赖从“测试”模块中排除?以下是我的“build.gradle ”模块
evaluationDependsOn(":app")
apply plugin: 'java'
dependencies {
def app = project(':app')
testCompile project(path: ':app', configuration: 'debugCompile')
def debugVariant = app.android.applicationVariants.find({it.name == 'debug'})
testCompile debugVariant.javaCompile.classpath
testCompile debugVariant.javaCompile.outputs.files
testCompile files(app.plugins.findPlugin("com.android.application").getBootClasspath())
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.powermock:powermock-api-mockito:1.6.1'
testCompile 'org.assertj:assertj-core:1.7.1'
}1
发布于 2015-02-05 15:22:45
使用“排除”属性移除依赖库。如下所示:
testCompile 'junit:junit:4.12‘{不包括'slf4j-android’}
我不知道你需要把它排除在哪个图书馆之外。要找出答案,请使用gradle列出库依赖项。
等级依赖
https://stackoverflow.com/questions/28339259
复制相似问题