public class LogLogcatRule
extends LoggingBaseRule
java.lang.Object | |||
↳ | org.junit.rules.ExternalResource | ||
↳ | android.support.test.rule.logging.LoggingBaseRule | ||
↳ | android.support.test.rule.logging.LogLogcatRule |
应用于测试类时,此Rule
尝试在执行测试方法之前清除设备上的Logcat缓冲区。 Rule
然后在测试方法执行后收集Logcat缓冲区中的所有内容,并将其记录到外部存储器上的文件中。 默认文件位置保持在getTestDir(String, String, int)
。 TestRule通过调用设备的logcat命令来执行这些操作。
clearLogcat()
and
dumpLogcat(String)
methods.
Usage:
\@Rule public LogLogcatRule mLogLogcatRule = new LogLogcatRule();
Public constructors |
|
---|---|
LogLogcatRule() |
|
LogLogcatRule(File logFileOutputDirectory, String fileName) |
Public methods |
|
---|---|
void |
afterTest() 测试运行后,将logcat缓冲区提取到文件。 |
void |
beforeTest() 测试运行前清除logcat缓冲区。 |
static void |
clearLogcat() 清除当前的logcat缓冲区。 |
File |
dumpLogcat(String logFileName) 将logcat缓冲区的当前状态转储到测试方法的日志记录目录中的文件。 |
String |
getDefaultLogFileName() 返回此规则类的默认日志文件名称。 |
Inherited methods |
|
---|---|
![]() android.support.test.rule.logging.LoggingBaseRule
|
|
![]() org.junit.rules.ExternalResource
|
|
![]() java.lang.Object
|
|
![]() org.junit.rules.TestRule
|
LogLogcatRule ()
LogLogcatRule (File logFileOutputDirectory, String fileName)
Parameters | |
---|---|
logFileOutputDirectory |
File
|
fileName |
String
|
void afterTest ()
测试运行后,将logcat缓冲区提取到文件。
void beforeTest ()
测试运行前清除logcat缓冲区。
File dumpLogcat (String logFileName)
将logcat缓冲区的当前状态转储到测试方法的日志记录目录中的文件。 在编写测试以在不同时间点记录logcat时,可以使用此方法。
Parameters | |
---|---|
logFileName |
String : where Logcat output is sent |
Returns | |
---|---|
File |
the File where output was logged |
String getDefaultLogFileName ()
返回此规则类的默认日志文件名称。 空返回值表示规则不会记录到文件。
Returns | |
---|---|
String |