Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

java - How to send an email of allure report?

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.

Thanks, Sudheer

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.5in
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);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...