Where is log output written to when using Robolectric + Roboguice?

后端 未结 6 1712
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 13:10

I\'m using Robolectric to test Android. I\'m running my tests via maven, e.g.

mvn -Dtest=LogTest test

If I have code that writes to the logs,

6条回答
  •  没有蜡笔的小新
    2021-02-01 13:28

    I am running robolectric-2.0-alpha-3.

    What worked for me was to set in the setUp method of my test the stream to stdout

    Something like:

    @Before
    public void setUp() throws Exception {
      ShadowLog.stream = System.out;
      //you other setup here
    }
    

    With this version of robolectric I had no success doing the same (ShadowLog.stream = System.out) in a custom TestRunner or in my TestLifeycleApplication.

    Setting the system property System.setProperty("robolectric.logging","stdout"); was of no effect as well, but it might works in previous versions.

提交回复
热议问题