Hi,
let me give you the background of my approach. I use Playwright as an automation tool framework
I have a set of test cases listed in the Testiny. Let’s say 10
I have only 5 test cases which run on the Azure Pipeline every time
for a given release version, I want to create a test run named after the version with those 5 test cases via API
And upload the results to the test run via API
Could you please guide me here… ?
Below are the approaches I have done so far:
I have created a test plan but couldn’t add the test cases to it via API
So I have created a test plan manually and added 5 test cases manually
I have created a Test run via API with the test plan ID and every time it creates a new one
I don’t see the Test cases added by doing like this
Kindly let me know if i am missing anything
Hi,
Adding test cases to a test run via API is almost the same as setting results for a test case in a test run: You create a mapping between test case and test run and also pass in the result.
The below API call uses the add_or_update
operation, so you can basically use it to add a test case or update it’s result within a test run:
curl -L -X POST 'https://app.testiny.io/api/v1/testrun/mapping/bulk/testcase:testrun?op=add_or_update' \
-H 'Content-Type: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '[{
"ids": { "testcase_id": 1234, "testrun_id": 3 },
"mapped": { "result_status": "PASSED" }
}]'
Please update the API-Key, the test case id + the run id to the respective values. The allowed values for the result status are NOTRUN,PASSED,FAILED,BLOCKED,SKIPPED
as you can see in the API documentation:
Adds/Removes/Updates mappings between entities (e.g. test cases, test runs, etc.) if the mapping is defined. Id values are named by entity e.g. 'testcase_id', 'testrun_id' (see request schema)
If you’re adding/updating test case results from a result file, e.g. from a JUnit XML file, using the Testiny CLI may be easier as explained here:
Hi,
While using the REST API directly is possible, it’s way easier to use the Testiny CLI to import test results. It automatically parses the result files, creates test cases and sets the results via the API.
In Azure pipelines, just create a new “Command line” task and then call the Testiny CLI as described in the documentation .
The Testiny CLI needs to be available in your repository or downloaded in the command line task (the latter is preferred, so you always have the latest version). You…
Hope this helps you get going
Regards,
Alex
from the below API load
--data-raw '[{ "ids": { "testcase_id": 1234, "testrun_id": 3 }, "mapped": { "result_status": "PASSED" } }]'
currently, this allows one at a time… can this allow multiple testcase_ids and multiple results at a go?
The API takes an array, so just pass in multiple objects, e.g.:
curl -L -X POST 'https://app.testiny.io/api/v1/testrun/mapping/bulk/testcase:testrun?op=add_or_update' \
-H 'Content-Type: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '[{
"ids": { "testcase_id": 1234, "testrun_id": 3 },
"mapped": { "result_status": "PASSED" }
}, {
"ids": { "testcase_id": 12345, "testrun_id": 2 },
"mapped": { "result_status": "FAILED" }
}]'
You can specify any test case and any test run, so you could also update multiple test runs in one go.
Regards,
Alex
I want to try it from the API using python
Sure, no prob, any programming language will do that can send API requests. The API documentation even has some code snippets for Python to start with.
Regards,
Alex