Android app behavior detective. Uncover quirks and anomalies with in your app with automation.
- Automated testing of Android apps
- Extensible plugin system for custom app-specific checks
- Support for both emulators and real Android devices
- Comprehensive logging and reporting
- Efficient artifact management
- macOS, Linux, or Windows
- Python 3.7+
- Android SDK and ADB (Android Debug Bridge)
- Android Emulator or physical Android device
droid-sherlock/
│
├── main.py # Entry point for the test framework
│
├── droid/
│ ├── __init__.py
│ ├── types.py # Configuration and custom type definitions
│ │
│ ├── test_framework/ # Core framework components
│ │ ├── __init__.py
│ │ ├── device_controller.py
│ │ ├── app_analyzer.py
│ │ └── test_runner.py
│ │
│ ├── plugins/ # Custom app-specific plugins
│ │ ├── __init__.py
│ │ ├── base_plugin.py
│ │ └── example_plugin.py
│ │
│ └── test_cases/ # Test case definitions
│ ├── __init__.py
│ ├── base_test.py
│ ├── example_test.py
│ └── network_test.py
│
├── configs/ # Configuration files
│ ├── default_config.yaml
│ └── example_config.yaml
│
├── requirements.txt # Python dependencies
│
├── .gitignore # Git ignore file
│
└── README.md # Project documentation
-
Clone the repository:
git clone https://github.com/skywalker212/droid-sherlock.git cd droid-sherlock
-
Set up a virtual environment:
python3 -m venv .venv source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
-
Install required packages:
pip install -r requirements.txt
-
Ensure Android SDK platform-tools are in your PATH.
-
For Emulator:
- Launch Android Studio
- Open AVD Manager (Tools > AVD Manager)
- Start your desired virtual device
-
For Real Device:
- Enable Developer Options on your Android device
- Enable USB Debugging in Developer Options
- Connect your device to your computer via USB
- Trust the computer if prompted on your device
- Open a terminal/command prompt
- Run the following command:
adb devices
- You should see output similar to:
The alphanumeric string (e.g.,
List of devices attached emulator-5554 device XXXXXXXX device
emulator-5554
orXXXXXXXX
) is your device ID.
-
If the app is currently open on the device:
- Run the following command:
adb shell dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'
- Look for a line like:
Here,
mCurrentFocus=Window{12345 u0 com.example.app/com.example.app.MainActivity}
com.example.app
is the package name andcom.example.app.MainActivity
is the activity name.
- Run the following command:
-
For more methods to find package names, refer to Android documentation or use tools like
aapt
.
- Copy
configs/default_config.yaml
toconfigs/your_app_config.yaml
. - Update your configuration file with the device ID, app package, and activity:
device_id: "your_device_id_here"
app_package: "com.example.app"
app_activity: "com.example.app.MainActivity"
plugins:
- example_plugin
test_cases:
- example_test
metadata:
version: "1.0"
-
Ensure your Android emulator is running or physical device is connected.
-
Run the test suite:
python main.py --config configs/your_app_config.yaml
-
Optional: Use the
--verbose
flag for more detailed output:python main.py --config configs/your_app_config.yaml --verbose
- Create a new file in the
droid/plugins/
directory, e.g.,my_custom_plugin.py
- Implement your plugin class, extending
BasePlugin
- Add your plugin to the configuration file
Example:
from droid.plugins.base_plugin import BasePlugin
class MyCustomPlugin(BasePlugin):
def run(self, device):
# Implement your custom checks here
self.logger.info("Running custom plugin")
return {"my_custom_check": "result"}
- Create a new file in the
droid/test_cases/
directory, e.g.,my_custom_test.py
- Implement your test case class, extending
BaseTest
- Add your test case to the configuration file
Example:
from droid.test_cases.base_test import BaseTest
class MyCustomTest(BaseTest):
def run(self, device, analyzer):
self.logger.info("Running custom test")
# Implement your test logic here
return {"custom_test_result": "passed"}
After running the tests, droid will generate a test report in the test_results
directory. This report includes:
- Test case results
- Plugin check results
- Screenshots and other artifacts
Review the generated log file and test report for detailed insights into your app's behavior.