Unable to get log.d or output Robolectrict + gradle

雨燕双飞 提交于 2019-12-22 12:50:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!