LogBatteryInformationRule

public class LogBatteryInformationRule
extends LoggingBaseRule

java.lang.Object
   ↳ org.junit.rules.ExternalResource
     ↳ android.support.test.rule.logging.LoggingBaseRule
       ↳ android.support.test.rule.logging.LogBatteryInformationRule


当应用于测试类时,此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

Public constructors

LogBatteryInformationRule()

LogBatteryInformationRule(File logFileOutputDirectory, String fileName)

Public methods

void afterTest()
void beforeTest()
String getDefaultLogFileName()

返回此规则类的默认日志文件名称。

Inherited methods

From class android.support.test.rule.logging.LoggingBaseRule
From class org.junit.rules.ExternalResource
From class java.lang.Object
From interface org.junit.rules.TestRule

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 ()

返回此规则类的默认日志文件名称。 空返回值表示规则不会记录到文件。

Returns
String