Run accessibility checks on a JUnit 4 sample repo
BrowserStack App Automate supports running JUnit 4 tests on a wide range of real Android and iOS devices. You can integrate your existing JUnit 4 test suites with App Automate to run accessibility checks on your mobile apps. This guide helps you run your first JUnit 4 test build on a real Android or iOS device on BrowserStack.
Prerequisites
- Ensure you have a BrowserStack Username and Access Key. Obtain your
username
andaccess key
from the Account & Profile section on the dashboard.
If you have not yet created an account, sign up for a Free Trial. - 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.
Run a sample build
Run a sample JUnit 4 test build using your preferred method on BrowserStack:
Get the sample project
Get the BrowserStack sample JUnit 4 project using one of the following options:
-
Option 1:
Download the sample JUnit 4 repository to your system. -
Option 2:
Clone the sample Git repository using the following command:git clone -b master https://github.com/browserstack/junit-appium-app-browserstack.git
-
Option 3:
Set up a new sample project using the Maven archetype. The following command creates a sample project with your BrowserStack credentials preconfigured.
ReplaceYOUR_USERNAME
andYOUR_ACCESS_KEY
with your BrowserStack credentials, and run one of the following commands based on your operating system and preference:
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-4: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-4:sdk"
Set up the dependencies
The JUnit 4 dependency is already included in the BrowserStack sample repository. If it is not set, add the following dependency to the pom.xml
file in the Android or iOS directory, based on your test platform:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
Configure the browserstack.yml file
The browserstack.yml
file contains the required capabilities to run your tests on BrowserStack. This file is platform-specific. Make sure you update the file that corresponds to your test platform (Android or iOS).
- Open the
browserstack.yml
file. - Set your BrowserStack
userName
andaccessKey
. - Set the
framework
:- Set it to
junit4
if you want to run only JUnit 4 tests. - Set it to
cucumber-junit4
if you want to run Cucumber tests using JUnit 4 as the test runner.
- Set it to
- Set the
accessibility
flag totrue
. The default value isfalse
.
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.
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!