Module sysbot.utils.robot.listener.postgresql
PostgreSQL Listener for Robot Framework BDD Database Integration
This module provides a Robot Framework listener that stores test results in PostgreSQL.
Usage
robot –listener sysbot.utils.robot.listener.postgresql.Postgresql:postgresql://user:pass@localhost/testdb:MyCampaign your_tests/
Example
robot –listener sysbot.utils.robot.listener.postgresql.Postgresql:postgresql://postgres:password@localhost/test_results:Sprint42 your_tests/
Requirements
- psycopg2-binary package must be installed
- PostgreSQL server must be running and accessible
Classes
class Postgresql (connection_string: str, campaign_name: str = 'Default Campaign')-
Robot Framework listener that stores test results in PostgreSQL database.
PostgreSQL is a powerful, enterprise-grade relational database suitable for large test suites and production environments.
The listener creates a hierarchical structure: - Test Campaign (top level) - Test Suite - Test Case - Keyword
Requires: psycopg2-binary Install with: pip install psycopg2-binary
Initialize the PostgreSQL listener.
Args
connection_string- PostgreSQL connection string (e.g., postgresql://user:pass@host/db)
campaign_name- Name of the test campaign (default: "Default Campaign")
Raises
ImportError- If SQLAlchemy or psycopg2 is not installed
Class variables
var ROBOT_LISTENER_API_VERSION
Methods
def close(self)-
Close database connection and update campaign end time.
Updates the campaign end timestamp, commits pending transactions, and closes the database connection.
def end_keyword(self, data, result)-
Called when a keyword ends.
Args
data- Robot Framework keyword data object.
result- Robot Framework keyword result object.
def end_suite(self, data, result)-
Called when a test suite ends.
Args
data- Robot Framework suite data object.
result- Robot Framework suite result object.
def end_test(self, data, result)-
Called when a test case ends.
Args
data- Robot Framework test data object.
result- Robot Framework test result object.
def start_keyword(self, data, result)-
Called when a keyword starts.
Args
data- Robot Framework keyword data object.
result- Robot Framework keyword result object.
def start_suite(self, data, result)-
Called when a test suite starts.
Args
data- Robot Framework suite data object.
result- Robot Framework suite result object.
def start_test(self, data, result)-
Called when a test case starts.
Args
data- Robot Framework test data object.
result- Robot Framework test result object.