|
1 |
| -# better-android-junit-report-aggregator |
2 |
| -A better JUnit XML Test Report Aggregator for Complex Android Build Systems |
| 1 | +# better-android-junit-report-aggregator: Android JUnit XML Test Report Aggregator |
| 2 | + |
| 3 | +[](https://plugins.gradle.org/plugin/io.github.bhargavms.junit.better-aggregator) |
| 4 | +[](LICENSE) |
| 5 | + |
| 6 | +better-android-junit-report-aggregator elegantly consolidates JUnit XML test results across multi-module, multi-project Gradle architectures in Android projects. It solves the challenge of collecting and accessing distributed test reports in complex build systems without modifying your existing test infrastructure. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +- **Seamless Multi-Module Collection**: Automatically discovers and aggregates test results from all modules |
| 11 | +- **Centralized Access**: Creates a single consolidated location for all test results |
| 12 | +- **CI/CD Integration**: Simplifies test outcomes for popular CI systems (GitHub Actions, CircleCI, Jenkins) |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +Add to your root build.gradle: |
| 17 | + |
| 18 | +```kotlin |
| 19 | +plugins { |
| 20 | + id("io.github.bhargavms.junit.better-aggregator") version "1.0.0" |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +Or using the legacy syntax: |
| 25 | + |
| 26 | +```groovy |
| 27 | +buildscript { |
| 28 | + repositories { |
| 29 | + gradlePluginPortal() |
| 30 | + } |
| 31 | + dependencies { |
| 32 | + classpath "io.github.bhargavms.junit.better-aggregator:io.github.bhargavms.junit.better-aggregator.gradle.plugin:1.0.0" |
| 33 | + } |
| 34 | +} |
| 35 | +
|
| 36 | +apply plugin: "io.github.bhargavms.junit.better-aggregator" |
| 37 | +``` |
| 38 | + |
| 39 | +## Basic Usage |
| 40 | + |
| 41 | +After applying the plugin, run your tests as normal: |
| 42 | + |
| 43 | +```bash |
| 44 | +./gradlew test |
| 45 | +``` |
| 46 | + |
| 47 | +Then, run the aggregation task: |
| 48 | + |
| 49 | +```bash |
| 50 | +./gradlew aggregateJUnitReports |
| 51 | +``` |
| 52 | + |
| 53 | +This will collect all JUnit XML reports into the `outputDir` directory that you configured. |
| 54 | + |
| 55 | +## Configuration |
| 56 | + |
| 57 | +Configure the plugin in your root build.gradle: |
| 58 | + |
| 59 | +```kotlin |
| 60 | +betterAggregator { |
| 61 | + // Output directory (relative to root project) |
| 62 | + outputDir.set("${project.getLayout().buildDirectory.dir("aggregated-reports").get().asFile.absolutePath}") |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +### CI Integration |
| 67 | + |
| 68 | +For GitHub Actions: |
| 69 | + |
| 70 | +```yaml |
| 71 | +- name: Run tests |
| 72 | + run: ./gradlew test |
| 73 | + |
| 74 | +- name: Aggregate test reports |
| 75 | + run: ./gradlew aggregateJUnitReports |
| 76 | + |
| 77 | +- name: Upload test reports |
| 78 | + uses: actions/upload-artifact@v2 |
| 79 | + with: |
| 80 | + name: test-reports |
| 81 | + # If using the outputDir configuration as defined in this README |
| 82 | + path: build/reports/aggregated-junit-reports |
| 83 | +``` |
| 84 | +
|
| 85 | +### Custom Tasks |
| 86 | +
|
| 87 | +Create a task that depends on test execution and report aggregation: |
| 88 | +
|
| 89 | +```kotlin |
| 90 | +tasks.register("testAndAggregate") { |
| 91 | + dependsOn("test", "aggregateJUnitReports") |
| 92 | + group = "Verification" |
| 93 | + description = "Runs tests and aggregates all reports" |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +## Compatibility |
| 98 | + |
| 99 | +- Gradle: 7.0+ |
| 100 | +- Kotlin: 1.5.0+ |
| 101 | +- Android Gradle Plugin: 4.1.0+ |
| 102 | +- Java: 8+ |
| 103 | + |
| 104 | +## How It Works |
| 105 | + |
| 106 | +The plugin: |
| 107 | + |
| 108 | +1. Scans your project structure to identify modules |
| 109 | +2. Searches for JUnit XML reports in configured directories |
| 110 | +3. Copies and organizes reports in the output directory |
| 111 | +4. Generates a consolidated overview of test results |
| 112 | + |
| 113 | +## Best Practices |
| 114 | + |
| 115 | +- Run the aggregation task after all tests complete |
| 116 | +- Include the task in your CI pipeline |
| 117 | +- Consider adding the output directory to your .gitignore file |
| 118 | + |
| 119 | +## Contributing |
| 120 | + |
| 121 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 122 | + |
| 123 | +1. Fork the repository |
| 124 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 125 | +3. Ensure you follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) |
| 126 | + Commit your changes (`git commit -m 'feat: Add some amazing feature'`) |
| 127 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 128 | +5. Open a Pull Request |
| 129 | + |
| 130 | +## License |
| 131 | + |
| 132 | +This project is licensed under the Apache 2.0 - see the [LICENSE](LICENSE) file for details. |
| 133 | + |
| 134 | +## Credits |
| 135 | + |
| 136 | +Developed by [Bhargav Srinivasan](https://github.com/bhargavms). |
| 137 | + |
| 138 | +## Similar Projects |
| 139 | + |
| 140 | +- [Kover](https://github.com/Kotlin/kotlinx-kover) - Kotlin coverage tool |
| 141 | +- [JaCoCo](https://github.com/jacoco/jacoco) - Java code coverage library |
0 commit comments