3

I am trying to send an email of the allure report generated by the framework using selenium. I have read the documentation but could not find any answer on how to send email.

Could any one please point me to the correct direction?

5 Answers 5

5

I know this question is pretty old. I found some answers for hosting allure using a third party and amazon aws s3 bucket. The first one is not good from a security standpoint and the second one involves money. So let's look at the below one which is free. Hope this helps people who are struggling with the same issue.

The below steps are detailed and it works a hundred percent.

  1. Download the allure command-line zip file from the maven central. 2.13.5 is the latest version when I am writing this. Zip file can be downloaded from the below link. The below link is not spam or malware. If you want, you can go this link manually from your browser as well :) https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.13.5/allure-commandline-2.13.5.zip
  2. Next step is extract this folder and move it to your testng repo code base. In my case I have kept the extracted folder under src/main/resources/config
  3. Each time you generate a allure-report from the java code, copy this allure-2.13.5 folder inside the report folder generated.
  4. Then you need to have two files to open the report in any machine(even in a machine which doesn't have allure installed). If you are using mac, then that file is a shell script open_report_mac.sh. If you are using windows, then that file is a batch script open_report_windows.bat.
  5. Now you can share the entire allure-report folder to anyone, they just need to run this batch file or shell script to view the report. I know this is a long method, but this works on machines even without allure.

Code for open_report_windows.bat:

SET PARENTDIR=%cd%
cd %PARENTDIR%\allure-2.13.5\bin
allure.bat open %PARENTDIR%

Code for open_report_mac.sh:

parent_dir=$(pwd)
cd $parent_dir/allure-2.13.5/bin
allure open $parent_dir

For those who doesn't know how to generate allure-repor programmatically below is my code. Important Note: You need to have allure installed on your mac for the below code to work.

public static void generateAllureReport() {
    String pattern = "dd-MM-yyyy_HH:mm:ss";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
    String reportfolder = "allure-report_" + simpleDateFormat.format(new Date());
    executeShellCmd("allure generate allure-results");
    executeShellCmd("mv allure-report " + reportfolder);
    executeShellCmd("cp -R src/main/resources/config/allure-2.13.5 "+reportfolder);
    executeShellCmd("cp src/main/resources/config/open_report_mac.sh "+reportfolder);
    executeShellCmd("cp src/main/resources/config/open_report_windows.bat "+reportfolder);
}

public static void executeShellCmd(String shellCmd) {
    try {
        Process process = Runtime.getRuntime().exec(shellCmd);
        process.waitFor();
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Error in Executing the command " + shellCmd);
    }
}
3

In case you only need to send the report summary - it is not possible yet. Here you can find the ticket for such feature.

0
2

With Allure Docker Service container you can get an emailable report. https://github.com/fescobar/allure-docker-service#customize-emailable-report

1

Allure generates a collection of files, that ought to be viewed via a web server. This due to the browsers restrictions on reading files from disk. This is needed to view Allure report correctly.

So in my mind you should post the result of Allure on a web server and the email the link to the report. As a side note, sending multi-megabyte email attachments with embedded JavaScript is rarely a good approach.

1

I've made a tool to build whole allure generate' result folder into a single html file viewable from browser: https://github.com/MihanEntalpo/allure-single-html-file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.