Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

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

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.

Based on your testing platform, navigate to the android or iOS directory.

Copy icon Copy
Copy icon Copy

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.

  1. Open the browserstack.yml file.
  2. Set your BrowserStack userName and accessKey.
  3. Set your projectName and buildName.
  4. Set the framework to nunit.
  5. Set the accessibility flag to true. The default value is false.
  6. Configure the accessibilityOptions property to set various accessibility testing options. For details, see Configuration options.
  7. 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.
  8. Specify all the device, OS, and OS version combinations that you want to test in the platforms section.
  9. 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.

browserstack.yml
Copy icon Copy

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.


Visit 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





Thank you for your valuable feedback

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle