Overview:

In this article, lets see how we can use DbBot + MySQL + Grafana to archive all our robot framework test results and create an robot framework test execution dashboard.

Personally, I would prefer to use TestArchiver + PostgreSQL + Grafana for storing my robot framework test execution results. By using this method you can leverage the archived results for AI Predictions / Analysis in future. You can find more details in RF + PostgreSQL + Grafana

Key Benefits:

  • Unified storage for the test run results
  • Archiving your test results to PostgreSQL database
  • Meeting the test data challenge for AI and ML

Metrics Covered:

  • Execution Status – Latest
  • Total Executions – Over Time Period
  • Average Pass and Failure Percentage
  • Top 5 Failed Test Cases
  • All Execution Status Over Time Period
  • Average Execution Time
  • Execution Trend Graph

Grafana & MySQL Integration:

MySQL Setup:

  • Download MySQL
  • Use the following link to setup MySQL DB
  • Create a new database schema robot_results using root user credential
  • Create a new user ‘ grafanaReader‘ and grand all privileges using the below commands

Grafana Setup:

  • Update Grafana data source to point to the MySQL instance
    • Click on Configuration Menu in the Left Panel and Select Datasource
    • Click on Add data source and select MySQL database
  • Enter MySQL server details as below and click on Save & Test. The connection should be successful.
Grafana MySQL

Once integrating MySQL and Grafana is completed, then the next step is to send the robot test results data to MySQL DB and enable the default Grafana dashboard.

Robot Framework & MySQL Integration:

Well at this point, I assume that you have Python 3+, Robot Framework installed already and you are running your automated test cases.

Additionally, if you have few robot test results output.xml files then it would be very helpful for you to follow the below details.

Python Library Setup:

We will be using the following libraries in order to parse the robot framework output.xml to MySQL database. Use the below command to install the libraries.

I have upgraded below libraries to Python 3+ and a slight update on the table data type to suit the standards of MySQL. Please use the following link to download the libraries – Download.

  • DbBot
  • DbBot-SQLAlchemy:

DbBot & DbBot-SQLAlchemy

DbBot is a Python script to serialize `Robot Framework` output files into a SQLite database. This way the future `Robot Framework` related tools and plugins will have a unified storage for the test run results.

DbBot-SQLAlchemy supports the following databases – MySQL | PostgreSQL | Oracle | SQLite. Please refer the below link if you would like to view additional options dbbot-sqlalchemy 

Now we are all set to push the report to MySQL DB. Please use the below command

Example:

Below is the sample command line code after replacing all the parameters specific to project for reference.

You can choose to store keywords and related data by using `-k` or `–also-keywords` flag.

Robot Framework Test Results in Grafana Dashboard:

Grafana Plugins:

We will have to install following grafana plugins to incorporate the robot framework dashboard.

  • Click on Configuration Menu in the Left Panel and Select Plugins
  • Click on Find more plugins Grafana.com and Search for below plugins

Select Panel under Plugin Type and Click on Pie Chart I D3 Gauge

Please follow the instruction in the below plugin installation page and install the plugins

I have created a decent looking dashboard and published them under grafana dashboards. You can download the pre-build dashboards using the following link Robot Framework Grafana Dashboard

The downloaded zip file should also contain the Grafana dashboards (in JSON format). Import those dashboard files in Grafana (You can find the Import feature under Home as shown below).

Once it successfully imports, It will create dashboards as shown below.