I,m trying to find a solution for my project.
I want to run testsuite and that results should be update in the management tool. It would be great if you give me a step by step solution to
How to map test cases with test run?
How to parse result statistics like name, status, time taken, failure message from the output.xml?
How to update same in the test management tool?
it depends a bit on your Test Management Tool.
Some tools (like TestRail or XRay) offer integrations for Robot Framework Results.
For others, you would need to create your own Integration.
So my answer below is a bit generic, but based on my experience with Test Rail.
If you create your own integration, it is helpful if the Test Management Tool offers some API you can access, e.g. a REST API.
Such an API will hopefully allow you to create Test Cases, Test Runs, upload Test Results & attachments etc.
In Robot Framework you have multiple ways how you can access the Test Results.
My recommended way is using the ResultVisitor and the Robot API.
Another way is using a Listener (which will allow you to upload results in “real-time” during the execution)
In that case, the approach could be:
- First decide, if the Test Cases shall already exist in your Test Management Tool beforehand (and you just need to “map” them to your results) or if your Integration shall also create them
- If the Test Cases already exist in your Test Managment Tool, decide on a way how to map them to your Robot Framerwork Tests.
One solution could be using a [TAG] to each Robot Framework Test which contains the id of the Test in the Test Management Tool.
You could also map them via their name only.
- After the Test Run, Parse your Robot Framework Test Results via the robot api (an example below)
Parsing Test Results | ROBOT FRAMEWORK
- Collect e.g, the Test Case IDs, Test Case Names and Test Status for each test
- If you need to create a Test Run in your Test Management Tool before you can map the results, you can now create that Test Run using the Test Case IDs you previously collected
- Now you can upload the parsed Test Status (for each Test) to the Test Run that you created
I’ve managed to collect Test Case IDs and have the necessary API components. However, I’m unsure about the best approach for uploading the test results to the testing tool. The issue is that the JUnit XML file, which contains the results, is generated only after the test execution is complete. This makes it challenging to place the upload process within a Teardown method.
I’m seeking guidance on how to handle this situation more effectively. Any advice or suggestions would be greatly appreciated.
You should do the processing of test results after robot execution, can’t be done in Teardowns.
Unless you have a Listener prepared for that.
As @HelioGuilherme66 said:
Do the upload to the Test Managment tool as a separate action after your test execution is complete and the output.xml has been written.
Do not try to do it from inside your Robot Framework Tests or Keywords.
Create a small Python script which will read the output.xml using the ResultVisitor, get the test ids (if needed), create the Test Run and Upload the results.
Then call that Python script after the execution.