我需要一种非常简单的方法来让 Robolectric 3.0 打开日志记录。我想查看 robolectric 的输出,而不仅仅是我的测试。我在网上试过的所有东西都不起作用。
我应该把它贴在哪里?
robolectric.logging.enabled = true
我尝试了以下方法:
在 test/java/res 的 robolectric.properties 文件中
在 test/java/resources 的 robolectric.properties 文件中
在 test/res 的 robolectric.properties 文件中
在 test/resources 的 robolectric.properties 文件中
在渐变中:
afterEvaluate {
project.tasks.withType(Test) {
systemProperties.put('robolectric.logging.enable', 'true')
}
}
在渐变中:
tasks.withType(Test) {
testLogging.exceptionFormat = 'full'
systemProperties.put('robolectric.logging.enable', 'true')
}
最佳答案
您可以添加到您的测试中:
@Before
public void init() {
ShadowLog.stream = System.out;
}
然后使用:gradle test -i
来源:Unable to get log.d or output Robolectrict + gradle
或者在build.gradle
中添加:
tasks.withType(Test) {
systemProperty "robolectric.logging", "stdout"
}
来源:https://github.com/studyplus/Studyplus-Android-SDK/blob/master/StudyplusAndroidSDK/build.gradle#L41
关于android - 如何打开 robolectric 日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31884798/