Overview
Allure integration enhances your Patrol test reports with:- Automatic screenshot capture at test completion
- Window hierarchy dumps for UI debugging
- Logcat logs embedded in reports
- Rich test execution timeline
- Categorized test results
- Trend analysis across test runs
Before you proceed, make sure you’ve completed the native setup guide.
Why Allure?
Allure provides a significantly more detailed view of your test execution compared to standard JUnit reports. It’s particularly useful for:- Debugging test failures with screenshots and logs
- Understanding test execution flow
- Tracking test trends over time
- Sharing results with non-technical stakeholders
Prerequisites
This guide assumes basic familiarity with Allure. If you’re new to Allure:Setup
Add dependencies
Update your app-level build.gradle file to add Allure dependencies:For more details, see the allure-kotlin README.
Create custom test runner
Create a new Kotlin file named This custom runner extends Patrol’s
AllurePatrolJUnitRunner.kt in the same directory as your MainActivityTest.java file (typically android/app/src/androidTest/java/your/package/):AllurePatrolJUnitRunner.kt
PatrolJUnitRunner and adds Allure’s reporting capabilities.Create allure.properties
Create a properties file at
android/app/src/main/res/allure.properties:android/app/src/main/res/allure.properties
This configuration is required if you’re using Android Test Orchestrator with the
clearPackageData option. Without it, test reports will be cleared after each test.Update MainActivityTest
Modify your What these rules do:
MainActivityTest.java file to add Allure rules for enhanced reporting:MainActivityTest.java
ScreenshotRule- Automatically captures a screenshot at the end of each testWindowHierarchyRule- Dumps the window hierarchy (view tree) at the end of each testLogcatRule- Embeds logcat output into the test report
Running Tests
Run your tests as usual with Patrol:Retrieving Reports
Download results from device
Use This command:
adb to retrieve the Allure results from the Android device:- Navigates to the test output directory on the device
- Creates a tar archive of the
allure-resultsfolder - Streams it to your local machine
- Extracts it to
build/reports/
Generate and view the report
Use the Allure CLI to generate and serve the report:This command generates the HTML report and opens it in your default browser.
If you don’t have Allure CLI installed:macOS (Homebrew):Linux:Windows:
Download from Allure releases and add to PATH.
Understanding Allure Reports
Report Features
Allure reports provide rich information about your test execution:Overview
Summary statistics, pass/fail rates, and test duration trends
Suites
Tests organized by suites and categories
Graphs
Visual representation of test results over time
Timeline
Chronological view of test execution
Behaviors
Tests grouped by features and stories
Packages
Tests organized by package structure
Test Details
For each test, Allure captures:- Execution time - How long the test took
- Steps - Detailed test steps (if annotated)
- Screenshots - Captured at test end
- Window hierarchy - UI structure at test end
- Logcat - Complete device logs
- Parameters - Test input parameters
- Categories - Custom test categorization
Advanced Configuration
Custom screenshot timing
Custom screenshot timing
Modify
ScreenshotRule to capture screenshots at different points:Filter logcat output
Filter logcat output
Customize logcat filtering in
LogcatRule:Generate static reports
Generate static reports
Instead of serving the report, generate static HTML files:This is useful for:
- Archiving reports
- Hosting on web servers
- Sharing via file systems
Integrate with CI/CD
Integrate with CI/CD
Add Allure report generation to your CI pipeline:
GitHub Actions
Best Practices
Run on Real Devices
Allure works best with real devices where all logs and screenshots are available.
Clean Between Runs
Clear previous results before new test runs to avoid mixing data:
Archive Reports
Save generated reports for historical comparison and trend analysis.
Review Failures
Use screenshots and logcat to quickly identify root causes of failures.
Troubleshooting
No results found
No results found
If you can’t retrieve results from the device:
- Verify tests ran successfully
- Check that
allure.propertiesis in the correct location - Ensure the device is connected:
adb devices - Try listing the directory manually:
Permission denied on device
Permission denied on device
If you get permission errors when retrieving results:
Build errors after adding dependencies
Build errors after adding dependencies
If Gradle sync fails:
- Verify all package names match your app
- Check that Allure versions are compatible (all 2.4.0)
- Clean and rebuild:
- Invalidate caches in Android Studio
Report shows no data
Report shows no data
If the report loads but shows no tests:
- Ensure tests actually ran (check adb logcat)
- Verify
AllurePatrolJUnitRunneris being used - Check that rules are properly added to
MainActivityTest - Confirm
allure-resultsdirectory exists and has JSON files
Next Steps
Firebase Test Lab
Run tests with Allure reporting on Firebase Test Lab
CI/CD Integration
Automate Allure report generation in your pipeline