Integrate NUnit test suite with App Accessibility testing
Learn how to add accessibility checks to your existing NUnit tests and generate comprehensive reports of accessibility issues.
BrowserStack supports out-of-the-box integration with NUnit. You can integrate your existing NUnit 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 NUnit test suite. To set one up, see Run accessibility checks on a sample repo.
- You are using .NET version 5.0 or above and NUnit version 3.0.0 or above.
- 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
Run the following command to install the BrowserStack SDK and create a browserstack.yml
file in the root directory of your project.
Ensure that your project is using .NET version 8 or below to avoid compatibility issues when running tests on BrowserStack.
dotnet add package BrowserStack.TestAdapter
dotnet build
dotnet browserstack-sdk setup --userName "YOUR_USERNAME" --accessKey "YOUR_ACCESS_KEY"
dotnet add package BrowserStack.TestAdapter
dotnet build
dotnet browserstack-sdk setup --userName "YOUR_USERNAME" --accessKey "YOUR_ACCESS_KEY"
[Only for Macs with Apple silicon] Install dotnet x64 on macOS
If you are using a Mac computer with Apple silicon chip (M1 or M2) architecture, use the given command.
cd #(project folder Android or iOS)
dotnet browserstack-sdk setup-dotnet --dotnet-path "<path>" --dotnet-version "<version>"
Here, <path>
refers to the absolute path to the directory where you want to save dotnet x64 and <version>
refers to the dotnet version which you want to use to run tests.
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
tonunit
. - 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:
dotnet build
dotnet test --filter <EXPRESSION> [other_args]
dotnet build
dotnet test --filter <EXPRESSION> [other_args]
dotnet build
dotnet64 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!