The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Insights

External Resources

More Info


Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Reporting to the Sauce Labs Dashboard

 Recording Pass/Failure Results

"Wait," you might be asking, "My test says 'Complete' but what happens if it fails?"

Unfortunately, Sauce has no way to determine whether your test passed or failed automatically, since it is determined entirely by your business logic. We can, however, tell Sauce about the results of our tests automatically using the Sauce python client:

pip install sauceclient

Then add this to your test:

# this authenticates you 
from sauceclient import SauceClient
sauce_client = SauceClient("philg", "45753ef0-4aac-44a3-82e7-b3ac81af8bca")

# this belongs in your test logic
sauce_client.jobs.update_job(driver.session_id, passed=True)

 Setting a Build Number

Now, you may want to associate this with a build id in your Continuous Integration pipeline. To do this, just include a build number in your desired capabilities:

desired_cap = {
    'platform': "Mac OS X 10.9",
    'browserName': "chrome",
    'version': "31",
    'build': "build-1234",
}

This is important for organizing tests in our new dashboard. Please see our docs for more information here

 Tagging Your Tests

You can also create custom tags for your tests that you can use to search on the archives page:

desired_cap = {
    'platform': "Mac OS X 10.9",
    'browserName': "chrome",
    'version': "31",
    'build': "build-1234",
    'tags': [ "tag1", "tag2", "tag3" ]
}

 Running Tests in Parallel

Now that you're running tests on Sauce, you may wonder how you can run your tests more quickly. Running tests in parallel is the answer! To do this we will need to use a third party test runner. The most popular third party test runners for Python are py.test and nose.

Include Page
_python_reporting
_python_reporting

Running Tests in Parallel

Include Page
_running_tests_in_parallel
_running_tests_in_parallel

 

 Parallel Testing with py.test

...