When debugging tests, a set of logs is always needed to get a basic picture of the failure and the device under test. Sources include: Logcat, Tradefed host log, screenshot, etc.
In order to make it generic and painless for any test writer to get those logs, Tradefed has a built-in mechanism to help collecting them.
To automatically collect some logs on failure, you can add the following option to your Tradefed command line:
--auto-collect LOGCAT_ON_FAILURE or --auto-collect SCREENSHOT_ON_FAILURE
To see the full list of possible values, checkout AutoLogCollector
For convenience, logcat and screenshot each have a direct flag:
--logcat-on-failure and --screenshot-on-failure
Note on suite modules (AndroidTest.xml)
Modules cannot direcly specify this option in the
AndroidTest.xml, but they
can use a module controller