为什么过程中给予测试运行器类空的InputStream? [英] why process give null inputstream in test runner class?
本文介绍了为什么过程中给予测试运行器类空的InputStream?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Android测试项目中,我简单看了的logcat
使用 ADB命令
In my android test project, I simply read the logcat
using adb command
喜欢,
public StringBuilder log=new StringBuilder();
public String line="";
public String temp="";
public void testSolo() throws Exception {
String baseCommand = "logcat -v time";
baseCommand += " ActivityManager:I "; // Info for my app
baseCommand += " *:S "; // Silence others
try {
Process logReaderProcess = Runtime.getRuntime().exec(baseCommand);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(logReaderProcess.getInputStream()));
while ((line =bufferedReader.readLine()) != null) {
log.append(line); // here readLine() returns null
}
}
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
不过,在这里串线
我总是得到的空值
而同样的事情总是在Android上运行活动的onCreate()
。
我不明白,为什么出现这种情况?
while the same thing always run in the android activity's onCreate()
.
I don't understand why this happen?
同样的事情在活动类,而不是在Android测试项目运行。
Same thing runs in activity class and not in the android test project.
我还添加了使用-permission为 READ_LOGS
和 WRITE_EXTERNAL_STORAGE
测试项目的manifest.xml
文件。
I also add use -permission for READ_LOGS
and WRITE_EXTERNAL_STORAGE
in test project's
manifest.xml
file.
有没有人知道它是如何工作的,或发生了什么?
Is there anybody knows how it works or what happens?
在此先感谢。
推荐答案
尝试添加
<uses-permission android:name="android.permission.READ_LOGS" />
你的清单。
这篇关于为什么过程中给予测试运行器类空的InputStream?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文