LogBatteryInformationRule
public class LogBatteryInformationRule
extends LoggingBaseRule
当应用于测试类时,此Rule
在测试方法执行之前重置电池信息(“统计信息”)。 Rule
然后在测试方法执行后收集电池信息并将其记录到外部存储器上的文件中。 默认文件位置保持在getTestDir(String, String, int)
。 该规则通过在batterystats
服务上执行转储来执行这些操作。
If the API level is less than 21 (Lollipop) this rule will do nothing since this dumpsys command isn't supported. This TestRule has limited use for short running tests and is meant for very long running tests.
The
Rule
's
before()
and
after()
methods can also be used for logging battery information across a test suite by manually invoking the methods in a
RunListener
.
Usage:
\@Rule public LogBatteryInformationRule mLogBatteryInformationRule = new LogBatteryInformationRule(); Summary
Inherited methods |
From class android.support.test.rule.logging.LoggingBaseRule
|
From class org.junit.rules.ExternalResource
void |
after() |
Statement |
apply(Statement arg0, Description arg1) |
void |
before() |
|
From class java.lang.Object
Object |
clone() |
boolean |
equals(Object arg0) |
void |
finalize() |
final Class<?> |
getClass() |
int |
hashCode() |
final void |
notify() |
final void |
notifyAll() |
String |
toString() |
final void |
wait(long arg0, int arg1) |
final void |
wait(long arg0) |
final void |
wait() |
|
From interface org.junit.rules.TestRule
abstract Statement |
apply(Statement arg0, Description arg1) |
|
Public constructors
LogBatteryInformationRule
LogBatteryInformationRule ()
LogBatteryInformationRule
LogBatteryInformationRule (File logFileOutputDirectory,
String fileName)
Parameters |
logFileOutputDirectory |
File
|
fileName |
String
|
Public methods
afterTest
void afterTest ()
beforeTest
void beforeTest ()
getDefaultLogFileName
String getDefaultLogFileName ()
返回此规则类的默认日志文件名称。 空返回值表示规则不会记录到文件。