问题
Has anyone being able to output System.out or Log.d traces from robolectric test to gradle console. I am using Robolectric Gradle test plugin I use the console to run my test since it is more painful to try to run it in AS, anyway I was trying to output the my test classes but unable to get them I've try from ShadowLog.stream=stdout to robolectric.logging in gradle file, and nothing . Has anyone able to achieve this.
Thanks.
回答1:
If you run test in Android Studio terminal you can do that. First you have to implement @Before:
@Before
public void init() {
ShadowLog.stream = System.out;
}
Next run your tests with --info parameter, like:
gradlew library:test --info
You will be able to use:
System.out.println("test");
ShadowLog.i("Serialization", "test");
Log.i("Serialization", "test");
来源:https://stackoverflow.com/questions/25005667/unable-to-get-log-d-or-output-robolectrict-gradle