Module sysbot.utils.robot.polarion
Polarion Plugin for Robot Framework Integration
This module provides utilities for integrating Robot Framework test results with Siemens Polarion ALM/QA. It includes: - xUnit post-processor for Polarion-compatible output using rebot - Test case ID mapping utilities for linking RF tests to Polarion STD - Metadata extraction and formatting for Polarion requirements
Usage
from sysbot.utils.robot.polarion import Polarion
polarion = Polarion() polarion.generate_xunit( output_xml='output.xml', xunit_file='polarion_results.xml', project_id='MY_PROJECT', test_run_id='TEST_RUN_001' )
Polarion Test Case Linking: Robot Framework tests can be linked to Polarion test cases using tags:
*** Test Cases ***
My Test Case
[Documentation] This test validates login functionality
[Tags] polarion-id:TEST-123 polarion-title:Login Test
# Test steps...
Requirements
- robotframework package must be installed
Classes
class Polarion-
Polarion exporter for Robot Framework test results.
This class provides methods to convert Robot Framework output.xml files into Polarion-compatible xUnit XML format with proper test case mapping.
Initialize the Polarion exporter.
Static methods
def extract_polarion_id(tags: List[str]) ‑> str | None-
Extract Polarion test case ID from Robot Framework tags.
Args
tags- List of tags from a Robot Framework test case
Returns
Polarion test case ID if found, None otherwise
Example
tags = ['smoke', 'polarion-id:TEST-123', 'regression'] extract_polarion_id(tags) # Returns 'TEST-123'
def extract_polarion_properties(tags: List[str]) ‑> Dict[str, str]-
Extract all Polarion custom properties from tags.
Args
tags- List of tags from a Robot Framework test case
Returns
Dictionary of custom properties for Polarion
Example
tags = ['polarion-testEnvironment:prod', 'polarion-assignee:jdoe']
Returns
def extract_polarion_title(tags: List[str]) ‑> str | None-
Extract Polarion test case title from Robot Framework tags.
Args
tags- List of tags from a Robot Framework test case
Returns
Polarion test case title if found, None otherwise
Methods
def generate_xunit(self,
output_xml: str,
xunit_file: str,
project_id: str | None = None,
test_run_id: str | None = None,
custom_properties: Dict[str, str] | None = None) ‑> str-
Generate Polarion-compatible xUnit XML from Robot Framework output.
This method uses rebot to generate a base xUnit file, then enhances it with Polarion-specific metadata and test case ID mappings.
Args
output_xml- Path to Robot Framework output.xml file
xunit_file- Path where xUnit XML file should be saved
project_id- Polarion project ID (optional)
test_run_id- Polarion test run ID (optional)
custom_properties- Additional custom properties for all tests
Returns
Path to generated xUnit file
Raises
FileNotFoundError- If output_xml doesn't exist
RuntimeError- If rebot command fails