# Atest Developer Workflow This document explains the practical steps for contributing code to atest. ##### Table of Contents 1. [Identify the code you should work on](#identify-the-code-you-should-work-on) 2. [Working on the Python Code](#working-on-the-python-code) 3. [Working on the TradeFed Code](#working-on-the-tradefed-code) 4. [Working on the VTS10-TradeFed Code](#working-on-the-vts10-tradefed-code) 5. [Working on the Robolectric Code](#working-on-the-robolectric-code) ## Identify the code you should work on Atest is essentially a wrapper around various test runners. Because of this division, your first step should be to identify the code involved with your change. This will help determine what tests you write and run. Note that the wrapper code is written in python, so we'll be referring to it as the "Python Code". ##### The Python Code This code defines atest's command line interface. Its job is to translate user inputs into (1) build targets and (2) information needed for the test runner to run the test. It then invokes the appropriate test runner code to run the tests. As the tests are run it also parses the test runner's output into the output seen by the user. It uses Test Finder and Test Runner classes to do this work. If your contribution involves any of this functionality, this is the code you'll want to work on.
For more details on how this code works, checkout the following docs:
- [General Structure](./atest_structure.md)
- [Test Finders](./develop_test_finders.md)
- [Test Runners](./develop_test_runners.md)
##### The Test Runner Code
This is the code that actually runs the test. If your change
involves how the test is actually run, you'll need to work with this
code.
Each test runner will have a different workflow. Atest currently
supports the following test runners:
- TradeFed
- VTS10-TradeFed
- Robolectric
## Working on the Python Code
##### Where does the Python code live?
The python code lives here: `tools/tradefederation/core/atest/`
(path relative to android repo root)
##### Writing tests
Test files go in the same directory as the file being tested. The test
file should have the same name as the file it's testing, except it
should have "_unittests" appended to the name. For example, tests
for the logic in `cli_translator.py` go in the file
`cli_translator_unittests.py` in the same directory.
##### Running tests
Python tests are just python files executable by the Python interpreter.
You can run ALL the python tests by executing this bash script in the
atest root dir: `./run_atest_unittests.sh`. Alternatively, you can
directly execute any individual unittest file. However, you'll need to
first add atest to your PYTHONPATH via entering in your terminal:
`PYTHONPATH=
For example, the tests for `tools/tradefederation/core/src/com/android/tradefed/testtype/suite/AtestRunner.java`
can be found in `tools/tradefederation/core/tests/src/com/android/tradefed/testtype/suite/AtestRunnerTest.java`.
##### Running tests
TradeFed itself is used to run the TradeFed unittests so you'll need
to build TradeFed first. See the
[TradeFed README](../../README.md) for information about setting up
TradeFed.
There are so many TradeFed tests that you'll probably want to
first run the test file your code change affected individually. The
command to run an individual test file is:
`tradefed.sh run host -n --class