Parrallel testing with Python, Cucumber, and Docker Compose

Integrating Allure Reporting, Jenkins, and Email Notifications

Aellur

After setting up parallel testing with Python, Cucumber, and Docker Compose, the next step is to integrate Allure reporting, automate the process with Jenkins, and set up email notifications for test results. This guide will walk you through these steps.

Prerequisites

  • Python installed on your system.
  • Docker and Docker Compose installed.

Steps

Allure Reporting

  1. Install Allure Command-Line Tool
    Ensure you have the Allure command-line tool installed. If not, follow the installation instructions on the Allure official documentation.(https://allurereport.org/docs/)

2. Extending the code with allure import and annotations and screenshot function

In the extended code the import allure library is added and also a capture screenshot function

def capture_screenshot(name):
    """Capture screenshot and attach to Allure report."""
    if driver is not None:
        screenshot = driver.get_screenshot_as_png()
        allure.attach(screenshot, name=name, attachment_type=allure.attachment_type.PNG)
    else:
        print("Driver is not initialized. Cannot capture screenshot.")

also per step an extra annotation is added for displaying what the step does and screenshots are added

@allure.step('I am using the selenium grid with "{browser_name}"')
@given('I am using the selenium grid with "<browser_name>"')


driver.get("https://www.learnautomatedtesting.com")
capture_screenshot("Visit Learn Automated Testing")

When all is added run the command

pytest –alluredir=allure-results

Then you will get this great report

Allure

libs used are pytest, pytest_bdd, webdriver,webdriver_manager, allure

Note: for users who use Behave install pip install behave allure-behave allure-python-commons

Command is: behave -f allure_behave.formatter:AllureFormatter -o ./allure-results ./features

3. Generate Allure Reports

After executing your tests, generate Allure reports using the command

for both use the results folder to create the report,this can be done automatically

allure serve <path_to_allure_results_directory>

Jenkins Integration with Allure

1. Install Jenkins

If you haven’t already, install Jenkins. Follow the official Jenkins installation guide.

2. Install Allure Jenkins Plugin

Navigate to Manage Jenkins > Manage Plugins > Available and search for Allure Jenkins Plugin. Install it.

3. Configure Allure Jenkins Plugin

Navigate to Manage Jenkins > Global Tool Configuration and add Allure Commandline with the path to your Allure installation.

4. Create a Jenkins Job

Create a new Jenkins job.
In the build section, add the necessary steps to execute your tests.
In the post-build actions, add Allure Report and specify the results directory.

Email Notifications

1. Configure Email Settings in Jenkins

Navigate to Manage Jenkins > Configure System and scroll down to the E-mail Notification section. Fill in the necessary details for your SMTP server.

2. Add Email Notification to Jenkins Job

Edit your Jenkins job.
In the post-build actions, add Editable Email Notification.
Configure the recipients, subject, and content as desired.
Ensure to attach the Allure report or provide a link to the Jenkins job for easy access.

3. Trigger Email on Job Completion

Ensure the email is sent out once the Jenkins job completes, either on success, failure, or both, based on your preference.

See updaed gitlab project in main

https://gitlab.com/learnautomatedtesting/paralleltestingpythonseleniumdocker

www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=ralphvanderhorst

Related articles

Integrating python Gmail api using Service Account to fetch e.g. oauth

Oauth

15 Oct 2023

Integrating python Gmail api using Service Account to fetch e.g. oauth

right-arrow.png
Mastering Waits in UI Automation

Selenium

6 Oct 2023

Mastering Waits in UI Automation

right-arrow.png
Parrallel testing with Python, Cucumber, and Docker Compose

Selenium

6 Oct 2023

Parrallel testing with Python, Cucumber, and Docker Compose

right-arrow.png

Are you ready to learn everything regarding testautomation

The guided path and the learnportal will make you a t-shaped tester. Guided by advanced material and hosted by a senior tester this portal will help you become professional

Contact us
image-11.WebP