【问题标题】:Robolectric 2.4 and android.util.LogRobolectric 2.4 和 android.util.Log
【发布时间】:2014-12-03 14:21:34
【问题描述】:

在使用 Robolectric 进行测试时,如何显示应用程序代码中的 Log.d() 输出?目前我使用的是 2.4 版。

【问题讨论】:

标签: unit-testing debugging logging robolectric gradlew


【解决方案1】:

我最近经常在我的测试代码中做next(因为缺乏与Android Studio的集成):

System.out.println("TEST");

然后运行gradle

gradle testDebug -i

【讨论】:

  • 我使用“gradlew test”来运行我的测试。我应该怎么做才能看到任何调试输出... System.out 或 Log.d()?
  • 首先使用“Robolectric + Log”搜索会导致 http://stackoverflow.com/questions/10219915/where-is-log-output-written-to-when-using-robolectric-roboguice。你检查了吗?
  • 是的,但答案对我没有帮助。也许我做错了什么。
  • 我看到了你的评论。因此,使用该解决方案只需使用 -i 标志运行 gradle
【解决方案2】:

将此作为 VM 参数添加到您的运行配置中(在 Android Studio 中):

-Drobolectric.logging=stdout

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多