如何打开机器人记录 [英] How to turn on robolectric logging
问题描述
我需要一种非常简单的方法来使Robolectric 3.0启用日志记录.我想查看robolectric的输出,而不仅仅是我的测试.我在网上尝试过的所有方法都无法正常工作.
I need a very simple way to get Robolectric 3.0 to turn on logging. I want to see the output from robolectric, not just my tests. Everything I tried off the web is not working.
我该贴在哪里?
robolectric.logging.enabled = true
我尝试了以下操作:
在test/java/res中的robolectric.properties文件中
In a robolectric.properties file in test/java/res
在test/java/resources中的robolectric.properties文件中
In a robolectric.properties file in test/java/resources
在test/res中的robolectric.properties文件中
In a robolectric.properties file in test/res
在test/resources中的robolectric.properties文件中
In a robolectric.properties file in test/resources
在gradle中:
afterEvaluate {
project.tasks.withType(Test) {
systemProperties.put('robolectric.logging.enable', 'true')
}
}
在gradle中:
tasks.withType(Test) {
testLogging.exceptionFormat = 'full'
systemProperties.put('robolectric.logging.enable', 'true')
}
推荐答案
您可以添加到测试中:
@Before
public void init() {
ShadowLog.stream = System.out;
}
然后使用: grad test -i
来源:无法获取log.d或输出Robolectrict+ gradle
tasks.withType(Test) {
systemProperty "robolectric.logging", "stdout"
}
来源: https://github.com/studyplus/Studyplus-Android-SDK/blob/master/StudyplusAndroidSDK/build.gradle#L41
这篇关于如何打开机器人记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!