Integrate Cucumber - JUnit 5 test suite with App Accessibility testing
Learn how to add accessibility checks to your existing functional tests and generate comprehensive reports of accessibility issues.
BrowserStack supports out-of-the-box integration with Cucumber tests using JUnit 5 as a test runner. You can integrate your existing functional test suites with App Accessibility testing to run accessibility checks on mobile apps. You can access the generated accessibility violation reports on the App Accessibility dashboard.
For Android devices, automated App Accessibility testing is supported on version 11 and above.
Prerequisites
- Ensure you have a BrowserStack Username and Access Key. Obtain your
userName
andaccessKey
from the Account & Profile section on the dashboard.
If you have not yet created an account, sign up for a free trial. - Ensure you have a functional Cucumber + JUnit 5 test suite. To set one up, see Run accessibility checks on a sample repo.
- Java 8 or higher is installed on your system.
- If you use the CLI to run tests, make sure that Apache Maven is installed on your system, the Maven environment variables are set, and the Maven
bin
directory is added to the system path ($PATH
) if you are using macOS or Linux systems. - Appium is installed on your system.
Integrate App Accessibility Automate to run accessibility checks
Set your BrowserStack credentials
Save your BrowserStack credentials as environment variables to make it easier to run your test suite from your local or CI environment.
Set the following values in either your Zsh (~/.zprofile
) or Bash (~/.profile
) shell configuration file.
export BROWSERSTACK_USERNAME=YOUR_USERNAME
export BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY
In your terminal or command line prompt, enter the following command:
setx BROWSERSTACK_USERNAME "YOUR_USERNAME"
setx BROWSERSTACK_ACCESS_KEY "YOUR_ACCESS_KEY"
set BROWSERSTACK_USERNAME=YOUR_USERNAME
set BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY
Install BrowserStack SDK using Maven archetype
Run the following command in your terminal or command line to add the browserstack-java-sdk
dependency and the browserstack.yml
file to your project.
Replace the placeholder values with your BrowserStack credentials and the path to your app in the following commands.
The minimum supported browserstack-java-sdk
version is 1.32.3
.
mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \
-DarchetypeArtifactId="browserstack-sdk-archetype-setup" -DarchetypeVersion=1.1 \
-DgroupId=com.browserstack -DartifactId=junit-appium-app-browserstack -Dversion=1.0 \
-DBROWSERSTACK_USERNAME=YOUR_USERNAME -DBROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY -DBROWSERSTACK_PROJECT_REPO=junit-appium-app-browserstack/junit-5:sdk
mvn archetype:generate -B -DarchetypeGroupId="com.browserstack" -DarchetypeArtifactId="browserstack-sdk-archetype-setup" -DarchetypeVersion="1.1" -DgroupId="com.browserstack" -DartifactId="junit-appium-app-browserstack" -Dversion="1.0" -DBROWSERSTACK_USERNAME="YOUR_USERNAME" -DBROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY" -DBROWSERSTACK_PROJECT_REPO="junit-appium-app-browserstack/junit-5:sdk"
Modify the configuration file
The browserstack.yml
file defines the required capabilities to run tests on BrowserStack. It is platform-specific and located in the corresponding platform folder (android/
or ios/
). Make sure you modify the file that corresponds to your testing platform.
- Open the
browserstack.yml
file. - Set your BrowserStack
userName
andaccessKey
. - Set your
projectName
andbuildName
. - Set the
framework
tocucumber-junit5
. - Set the
accessibility
flag totrue
. The default value isfalse
. - Configure the
accessibilityOptions
property to set various accessibility testing options. For details, see Configuration options. - Add the relative or absolute path of the app you want to test in the
app
property. For example,app: ./examples/BStackSampleApp.apk
.
You can upload an Android app (.apk
or.aab
file) or an iOS app (.ipa
file) from your local filesystem. - Specify all the device, OS, and OS version combinations that you want to test in the
platforms
section. - Save the file.
The projectName
and buildName
config must be static and not change across different runs of the same build. This is a deviation in approach as specified by BrowserStack App Automate since Automated tests will automatically identify different build runs.
Run the automated test
From your platform folder (Android or iOS), run the following command:
mvn clean
mvn verify -P sample-test
View the Accessibility test report
After the test completes, view the report in your project folder on the App Accessibility dashboard.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!