Parrallel testing with python, cucumber, and docker compose

06.10.2023 | by Ralph Van Der Horst

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

by Ralph Van Der Horst

arrow right
back to blog

share this article

Relevant articles

Mastering Waits in UI Automation

06.10.2023

Mastering Waits in UI Automation

Parrallel testing with Python, Cucumber, and Docker Compose

06.10.2023

Parrallel testing with Python, Cucumber, and Docker Compose

Medior: Use 2fa and UI testautomation

09.09.2023

Medior: Use 2fa and UI testautomation