public void before() throws Throwable {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    ProcessBuilder processBuilder=new ProcessBuilder();
    processBuilder.command("logcat","-c");
    processBuilder.redirectErrorStream();
    Process process=processBuilder.start();
    process.waitFor();
    if (process.exitValue() != 0) {
      Log.e(LOG_TAG,"Error while clearing logcat, exitValue=" + process.exitValue());
    }
  }
}

public void before ( ) throws Throwable { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . M ) { ProcessBuilder processBuilder = new ProcessBuilder ( ) ; processBuilder . command ( "logcat" , "-c" ) ; processBuilder . redirectErrorStream ( ) ; Process process = processBuilder . start ( ) ; process . waitFor ( ) ; if ( process . exitValue ( ) != 0 ) { Log . e ( LOG_TAG , "Error while clearing logcat, exitValue=" + process . exitValue ( ) ) ; } } }
clear logcat buffer prior to test run .
