Generate Reports within CI/CD
With axe DevTools Reporter, you can now generate self-contained reports right within your continuous integration / continuous deployment (CI/CD) pipeline.
Follow the basic steps below to integrate the reporter into your Android or iOS pipeline.
Integration into an Android Pipeline
Set up your Automated Tests
-
Update your automated tests to save results locally, which can then be used to generate the report.
-
Add the script below to your app's
build.gradle
file, below theandroid
block, and ensure it's not within another Gradle task. Add your app package name in thepackageName
variable. This script will move the results generated from your automated run to the build folder's report directory.
def reportsDirectory = "$buildDir/reports/androidTests/connected/axe"
def packageName = "your.app.package.name.here"
def createAndroidFolderDirectoryTask = task('createAndroidFolderDirectoryTask', type: Exec, group: 'reporting') {
executable "${android.getAdbExecutable().toString()}"
args 'shell', 'mkdir', '-p', '/storage/emulated/0/Android/data/' + packageName + '/files/AxeTestCases'
}
def clearAndroidDirectoryTask = task('clearAndroidDirectoryTask', type: Exec, group: 'reporting') {
executable "${android.getAdbExecutable().toString()}"
args 'shell', 'rm', '-r', '/storage/emulated/0/Android/data/' + packageName + '/files/AxeTestCases'
}
def fetchAndroidFolderAxeReportsTask = task('fetchAndroidFolderAxeReportsTask', type: Exec, group: 'reporting') {
executable "${android.getAdbExecutable().toString()}"
args 'pull', '/storage/emulated/0/Android/data/' + packageName + '/files/AxeTestCases', reportsDirectory
dependsOn {
createAndroidFolderDirectoryTask
}
finalizedBy {
clearAndroidDirectoryTask
}
doFirst {
new File(reportsDirectory).mkdirs()
}
}
def createDirectoryTask = task('createDirectoryTask', type: Exec, group: 'reporting') {
executable "${android.getAdbExecutable().toString()}"
args 'shell', 'mkdir', '-p', '/storage/emulated/0/Documents/AxeTestCases'
}
def clearDirectoryTask = task('clearDirectoryTask', type: Exec, group: 'reporting') {
executable "${android.getAdbExecutable().toString()}"
args 'shell', 'rm', '-r', '/storage/emulated/0/Documents/AxeTestCases'
finalizedBy {
fetchAndroidFolderAxeReportsTask
}
}
def fetchAxeReportsTask = task('fetchAxeReportsTask', type: Exec, group: 'reporting') {
executable "${android.getAdbExecutable().toString()}"
args 'pull', '/storage/emulated/0/Documents/AxeTestCases', reportsDirectory
dependsOn {
createDirectoryTask
}
finalizedBy {
clearDirectoryTask
}
doFirst {
new File(reportsDirectory).mkdirs()
}
}
tasks.configureEach { task ->
if (task.name == 'connectedDebugAndroidTest') {
task.finalizedBy {
fetchAxeReportsTask
}
}
}
Steps to Generate the Report
-
Log in to our private artifactory, Agora with your Deque credentials. From the "Welcome, < email >" drop-down, select "Edit Profile". Copy your API key for use in the below script. For an automated pipeline, look into having this API key available in your environment variables or project secrets for your platform.
-
Before running your tests or build, fetch the reporter. Here's a script to get started:
# Compatible with a Mac runner on GitHub Actions. Make changes to the Reporter download type and location based on your pipeline requirements.
AGORA_API_KEY='<YOUR_API_KEY>'
curl --compressed \
-H "X-JFrog-Art-Api: ${AGORA_API_KEY}" \
"https://agora.dequecloud.com/artifactory/axe-devtools-reporter-cli/prod/4.10.0/pkgs/@axe-devtools/reporter-cli-macos" \
--output "/Users/runner/reporter"
chmod +x /Users/runner/reporter
-
Build your app and run your tests
-
Once tests have finished, execute the reporter and specify the file path of the result JSON files.
DEQUE_RESULTS="../ContainingFolder"
/Users/runner/reporter ${DEQUE_RESULTS} "AxeReport" --format=html
Customize your output format (--format
) with html
, junit
or csv
.
Integration into an iOS Pipeline
Setup your Automated Tests
Update your automated tests to save results locally, which can then be used to generate the report.
Steps to Generate the Report
-
Log in to our private artifactory, Agora with your Deque credentials. From the "Welcome, < email >" drop-down, select "Edit Profile". Copy your API key for use in the below script. For an automated pipeline, look into having this API key available in your environment variables or project secrets for your platform.
-
Before running your tests or build, fetch the reporter. Here's a helpful script to get started:
AGORA_API_KEY='<YOUR_API_KEY>'
curl --compressed \
-H "X-JFrog-Art-Api: ${AGORA_API_KEY}" \
"https://agora.dequecloud.com/artifactory/axe-devtools-reporter-cli/prod/4.10.0/pkgs/@axe-devtools/reporter-cli-macos" \
--output "/Users/runner/reporter"
chmod +x /Users/runner/reporter
-
Build your app and run your tests.
-
Once tests have finished, execute the reporter and specify the file path of the result JSON files.
DEQUE_RESULTS="../ContainingFolder"
/Users/runner/reporter ${DEQUE_RESULTS} "AxeReport" --format=html
Customize your output format (--format
) with html
, junit
or csv
.