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.gradlefile, below theandroidblock, and ensure it's not within another Gradle task. Add your app package name in thepackageNamevariable. 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, <your_email>" drop-down, select 'Edit Profile'.
- Click 'Generate an Identity Token'.
- A dialog box will open and show the option to copy the Reference Token.
- Create a distinctive name for the Identity Token and add that in the description. The example below uses
AGORA_IDENTITY_TOKENas the name - Select 'Next'.
- In the next dialog box, please copy your Identity Token for use in the below script. For an automated pipeline, look into having this token available in your environment variables or project secrets for your platform.
The Identity Token is accessible from within the dialog only, and you will not be able to view it again after closing the dialog. This token will expire 11 months and 30 days after its creation.
- 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_IDENTITY_TOKEN='<YOUR_AGORA_IDENTITY_TOKEN>'
curl --compressed \
-H "X-JFrog-Art-Api: ${AGORA_IDENTITY_TOKEN}" \
"https://agora.dequecloud.com/artifactory/axe-devtools-reporter-cli/prod/4.11.1/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=htmlCustomize 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, <your_email>" drop-down, select "Edit Profile".
- Click 'Generate an Identity Token'.
- A dialog box will open and show the option to copy the Reference Token.
- Create a distinctive name for the Identity Token and add that in the description. The example below uses
AGORA_IDENTITY_TOKENas the name. - Select 'Next'.
- In the next dialog box, please copy your Identity Token for use in the below script. For an automated pipeline, look into having this token available in your environment variables or project secrets for your platform.
The Identity Token is accessible from within the dialog only, and you will not be able to view it again after closing the dialog. This token will expire 11 months and 30 days after its creation.
- Before running your tests or build, fetch the reporter. Here's a helpful script to get started:
AGORA_IDENTITY_TOKENY='<YOUR_AGORA_IDENTITY_TOKEN>'
curl --compressed \
-H "X-JFrog-Art-Api: ${AGORA_IDENTITY_TOKEN}" \
"https://agora.dequecloud.com/artifactory/axe-devtools-reporter-cli/prod/4.11.1/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=htmlCustomize your output format (--format) with html, junit or csv.
