Skip to main content
No Result Found

Test Observability on Pytest

Quick start guide to integrate BrowserStack Test Observability with Pytest.

Prerequisites

Following are the prerequisites to use Test Observability with Pytest:

  • You have a Pytest (v4.2.0 or higher) test suite.
  • You may run your tests on BrowserStack Automate or even on any other cloud provider or even locally.
  • Your tests can be unit / integration / functional or of any nature.

Integrate with Test Observability

You can use BrowserStack Test Observability both when you’re using BrowserStack’s devices and browsers to run your functional end-to-end tests and also if you’re running tests locally on your laptop/CI system or even when you’re using some other cloud provider.

Not only that, Test Observability is agnostic to the type of testing and hence you could also integrate it with your unit or integration test suite written using Pytest.

Please select your setup below to get started with an awesome debugging experience with Test Observability:

Install the latest SDK version

Go to your Pytest project’s root directory and run the following commands to update or install the BrowserStack SDK, set it up using your credentials, and verify the installed version:

Terminal
Copy icon Copy


Ensure that you have at least browserstack-sdk v1.17.4 before proceeding.

Modify your browserstack.yml config file

After installing the SDK, a browserstack.yml config file will be created at the root level of your project. This file holds all the required capabilities to run tests on BrowserStack.

Copy the contents of the following config file and set it in your project’s browserstack.yml file:

browserstack.yml
Copy icon Copy

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 Automate or App Automate as Test Observability will automatically identify different build runs.

Restrict the characters in your projectName and buildName to alphanumeric characters (A-Z, a-z, 0-9), underscores (_), colons (:), and hyphens (-). Any other character will be replaced with a space.

Run your test suite with Test Observability

Prepend browserstack-sdk to the command you use to run your test. For example, if you use the command pytest <path-to-test-file> to run your test suite, you can run the following command from your project’s root directory to run your test suite with BrowserStack:

Terminal
Copy icon Copy


Post build run completion, you’ll be able to see the build run report along with all necessary debugging information.

Update to the latest SDK version

Go to your Pytest project’s root directory and run the following commands to update to the latest version of BrowserStack SDK, and verify the installed version:

Terminal
Copy icon Copy


Ensure that you have at least browserstack-sdk v1.17.4 before proceeding.

Update your browserstack.yml config file

As you’re an existing browserstack-sdk user, you must already be having a browserstack.yml config file at the root level of your project.

Test Observability mandatorily needs the following configurations in the file. You need not change anything but you have to ensure that the values of the buildName and projectName variables are not changing across different build runs.

browserstack.yml
Copy icon Copy

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 Automate or App Automate as Test Observability will automatically identify different build runs.

Restrict the characters in your projectName and buildName to alphanumeric characters (A-Z, a-z, 0-9), underscores (_), colons (:), and hyphens (-). Any other character will be replaced with a space.

Run your test suite with Test Observability

Prepend browserstack-sdk to the command you use to run your test. For example, if you use the command pytest <path-to-test-file> to run your test suite, you can run the following command from your project’s root directory to run your test suite with BrowserStack:

Terminal
Copy icon Copy


Post build run completion, you’ll be able to see the build run report along with all necessary debugging information.

Install the latest SDK version

Go to your Pytest project’s root directory and run the following commands to update or install the BrowserStack SDK, set it up using your credentials, and verify the installed version:

Terminal
Copy icon Copy


Ensure that you have at least browserstack-sdk v1.17.4 before proceeding.

Modify your browserstack.yml config file

After installing the SDK, a browserstack.yml config file will be created at the root level of your project. This file holds all the required capabilities to run tests on BrowserStack.

Copy the contents of the following config file and set it in your project’s browserstack.yml file:

browserstack.yml
Copy icon Copy

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 Automate or App Automate as Test Observability will automatically identify different build runs.

Restrict the characters in your projectName and buildName to alphanumeric characters (A-Z, a-z, 0-9), underscores (_), colons (:), and hyphens (-). Any other character will be replaced with a space.

Run your test suite with Test Observability

Prepend browserstack-sdk to the command you use to run your test. For example, if you use the command pytest <path-to-test-file> to run your test suite, you can run the following command from your project’s root directory to run your test suite with BrowserStack:

Terminal
Copy icon Copy


Post build run completion, you’ll be able to see the build run report along with all necessary debugging information.

Visit Test Observability

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