dimanche 8 avril 2018

How can I refresh a folder with Java code?

What I am trying to do:

Generate a test report after the test execution is done and then email it( I am using Maven, cucumber and RestAssured).

The issue that I am facing:

Everything from the above mentioned is happening, except the test report which gets e-mailed is actually from previous test execution. That is, the report or the folder that has the report, is not getting refreshed when the code to email the report runs.

Is there any way to refresh the folder at the end of the test execution through maven or is there any other way with which I can send the latest test report..?

Any pointer is much appreciated. Below is my Cucumber runner code,

@RunWith(Cucumber.class)
@CucumberOptions(
    features = "src/test/resources/Feature"
    ,glue= "com/sss/tests/RestApi"
    ,tags = {"@TestInDevelopment"}
    ,plugin = {"com.cucumber.listener.ExtentCucumberFormatter:/Report.html"}        
    ,format = {"pretty","html:target/cucumber"}
    ,monochrome = true
    )

public class TestRunner { 
static Configurations config = new Configurations();

@BeforeClass
public static void setup(){

    /*
     * Loading the log4j configurations, before the start of test execution
     */     
    String folderName = "PropertyFiles";
    String fileName = "log4j.properties";
    PropertyConfigurator.configure(config.getResourcePath(folderName)+fileName);

}

@AfterClass
public static void teardown() throws UnknownHostException, IOException, InterruptedException {

    /*
     * Loading the configuration file for the test execution report and setting up the user name, OS info and host details in the report
     */     
    Reporter.loadXMLConfig(new File(config.getResourcePath("Resources")+"extent-config.xml"));
    Reporter.setSystemInfo("USER", System.getProperty("user.name"));
    Reporter.setSystemInfo("OS", System.getProperty("os.name"));
    Reporter.setSystemInfo("HOST NAME", InetAddress.getLocalHost().getHostName());  

   /*
    * After the test execution is completed, parsing the generated test execution report to to see if there is any failures and based on that,
    * sending the Build Success/Failure e-mail to the configured mail list
    */        
    HTML_TestExecutionReportParser testExecutionStatusParser = new HTML_TestExecutionReportParser();    
    TestExecutionReportEmailSender testExecutionReportMailSender = new TestExecutionReportEmailSender();        
    testExecutionReportMailSender.sendTestExecutionReportEmail(testExecutionStatusParser.isAssertionFailureFound(), testExecutionStatusParser.errorsFoundList());     

}

}

Aucun commentaire:

Enregistrer un commentaire