This sample elaborates the MSTest Integration with BrowserStack.
To perform tests using SDK, please checkout the sdk branch
- Clone the repository.
- Open the solution
mstest-appium-app-browserstack.sln
in Visual Studio. - Install dependencies using NuGet Package Manager:
dotnet restore
- Build the solution
-
Add your BrowserStack Username and Access Key to the
Config/*.json
files in the project.{ "userName": "BROWSERSTACK_USERNAME", "accessKey": "BROWSERSTACK_ACCESS_KEY", }
-
Alternatively, you can set environment variables given below. Note that the creds supplied in the config json files above, takes precedence over environment variables. In order to use env variables, remove the
userName
andaccessKey
from the config json files altogether.BROWSERSTACK_USERNAME
BROWSERSTACK_ACCESS_KEY
You can get your browserstack credentials from here
-
Upload the app using the Browserstack REST API.
-
The response contains the app hashed id:
{ "app_url": "bs://<app_hashed_id>" }
-
Paste this app hashed id to the corresponding config file. For Example: The sample android app used for Android Single Test can be found here. Upload the app and paste the hashed id here.
-
To run tests, execute the following command:
dotnet test
-
To run tests on Android/iOS, provide
<os>
to the below command. Where os can take either of two values:Android
oriOS
.dotnet test <os>
-
To run the single test, execute the following command:
dotnet test <os> --filter SingleTest
-
To run tests in parallel, execute the following command:
dotnet test <os> --filter ParallelTest
-
To run local tests, execute the following command:
dotnet test <os> --filter LocalTest
Understand how many parallel sessions you need by using our Parallel Test Calculator
-
You can view your test results on the BrowserStack automate dashboard
-
To test on a different set of devices or build a set of appium capabilities, use our Capability Builder
-
You can export the environment variables for the Username and Access Key of your BrowserStack account
- For Unix-like or Mac machines:
export BROWSERSTACK_USERNAME=<browserstack-username> && export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
- For Windows Cmd:
set BROWSERSTACK_USERNAME=<browserstack-username> set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
- For Windows Powershell:
$env:BROWSERSTACK_USERNAME=<browserstack-username> $env:BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>