1

I'm implementing an automated testing system the stb-tester ONE. I've been able to run tests automatically using the REST API and now I'm implementing the Test Reporting module.

I want to be able to download the test results for a test-job in CSV format so I can feed it into my reporting system. For each test I want Test run ID, test case name, start timestamp, duration, result (pass/fail/error), failure reason (that is, the exception that was raised or the assertion that failed).

Can you give me an example of how to do this from Python?

Disclaimer: I work on stb-tester and am an employee of stb-tester.com Ltd. This is a sanitised version of a question we've previously received through other support channels published here in an effort to seed a stb-tester support community on stackexchange.

1 Answer 1

2

The stb-tester ONE provides an http REST API for retrieving test results which is documented here. In particular you will be interested in test-results endpoints:

Here's an example of using these APIs with Python requests to get the results from a test job into a CSV file called results.csv:

stb_tester_one_hostname = "stb-tester-one-c03fd562ae33"
out_csv_filename = "results.csv"
job_uid = "/stb-tester-one-example/0a23/972"

import csv
import requests

# https://stb-tester.com/manual/rest-api#get-list-of-results-for-a-job
url = "http://{hostname}/api/v1/jobs/{job_uid}/results".format(
    hostname=stb_tester_one_hostname, job_uid=job_uid)
results = requests.get(url).json()

writer = csv.writer(open(out_csv_filename, "w"))
writer.writerow(["result_id", "job_uid", "result_url", "start_time",
                 "end_time", "test_pack_sha", "test_case", "result",
                 "failure_reason"])
for testrun in results:
    writer.writerow(
        testrun["result_id"],
        testrun["job_uid"],
        testrun["result_url"],
        testrun["start_time"],
        testrun["end_time"],
        testrun["test_pack_sha"],
        testrun["test_case"],
        testrun["result"],
        testrun["failure_reason"])

Disclaimer: I work on stb-tester and am an employee of stb-tester.com Ltd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.