哪里是日志输出写入使用Robolectric + Roboguice何时? [英] Where is log output written to when using Robolectric + Roboguice?

查看:195
本文介绍了哪里是日志输出写入使用Robolectric + Roboguice何时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Robolectric测试Android系统。我跑我通过行家的测试,例如。

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

mvn -Dtest=LogTest test

如果我有code,它写入日志,如

If I have code that writes to the logs, such as

Log.d("TAG", "blah");

或使用Roboguice的 LN

Ln.d("blah");

我没有看到Maven的万无一失日志任何输出(文本文件)。

I don't see any output in maven's surefire logs (text files).

在理想情况下,其实我是想简单的日志报表去到控制台。我可以通过使用写入控制台的System.out.println(嗒嗒),当然,我宁愿使用支持的日志记录API。

Ideally, I actually want simple log statements to go to the console. I can write to the console by using System.out.println("blah"), but of course I'd rather use the supported logging APIs.

所以,我的问题是,为什么我没有看到日志输出一切,我怎么能得到写入控制台的日志信息?

So my question is, why am I not seeing log output at all, and how can I get the log messages written to the console?

推荐答案

我正在运行的 robolectric-2.0-α-3

什么工作对我来说是的设置方法来设置我的测试的流标准输出

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

是这样的:

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

通过这个版本robolectric我没有成功做同样的( ShadowLog.stream = System.out的)在一个自定义的TestRunner或在我的TestLifeycleApplication。

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

设置系统属性 System.setProperty(robolectric.logging,标准输出); 是没有效果为好,但它可能在$ P $作品pvious版本。

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

这篇关于哪里是日志输出写入使用Robolectric + Roboguice何时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆