Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

End time on tests not being set correctly - total time taken incorrect #815

@TinyCamera

Description

@TinyCamera

I am seeing this issue on 3.0.0 and 3.0.3.

I am parsing an XML test report and generating an Extent Report. I parse the start and end time of each test use them to set the start and end time of each Extent Report explicitly.

In the Extent report, the start time is displayed correctly but the end time is being set to the time the report is generated(not the end time explicitly set). This gives each test a massively inflated incorrect execution time.

I can gaurentee the start and end time are in the same format and being parsed correctly.

screen shot 2017-03-20 at 11 10 02 am

Heres the code for generating the report.


import java.util.List;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;


public class ExtentReoprtGenerator {
	String outputFile; 
	XmlReport report;
	ExtentReports extentReport;

	public ExtentReoprtGenerator(String _outputFile, XmlReport _report){

		outputFile = _outputFile;
		report = _report;

		ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(outputFile);
		extentReport = new ExtentReports();
		extentReport.attachReporter(htmlReporter);
	}

	public void generate(){
		System.out.println(String.format("Generating Extent report %s", outputFile));
		addTests();
		extentReport.flush();
	}

	private void addTests(){
		for(XmlTest test: report.getTests()){
			ExtentTest extentTest = extentReport.createTest(test.getTestName());

			addSteps(extentTest, test.getTestSteps());
			
			if(test.getStartTime()!=null){
				extentTest.getModel().setStartTime(test.getStartTime());
				extentTest.getModel().setEndTime(test.getEndTime());
			}else{
				extentTest.getModel().setStartTime(report.getRunDate());
				extentTest.getModel().setEndTime(report.getRunDate());
			}
		}
	}

	private void addSteps(ExtentTest test, List<Step> steps){
		if (steps.isEmpty()){
			test.log(Status.SKIP, "Not tests steps run");
		}
		for(Step step: steps){
			switch (step.getLogStatus()) {
			case FAIL:
				test.fail(step.getName() +"<br>"+ step.getMessage());
				break;
			case PASS:
				test.pass(step.getName() +"<br>"+ step.getMessage());
				break;

			default:
				break;
			}
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions