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

Commit

Permalink
fix #815
Browse files Browse the repository at this point in the history
  • Loading branch information
anshooarora committed Mar 23, 2017
1 parent a317faf commit fd87933
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ public interface ExtentReporter extends TestListener, ReportAggregatesListener {
* Time of when ExtentReports instance was created
*/
void setStartTime(Date d);

/*
* Time when the last log event occurred to determine the time report was ended
*/
void setEndTime(Date d);
}
10 changes: 10 additions & 0 deletions src/main/java/com/aventstack/extentreports/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract class Report implements IReport {
protected boolean usesManualConfiguration = false;

private Date reportStartDate;
private Date reportEndDate;

private Status reportStatus = Status.PASS;

Expand Down Expand Up @@ -136,6 +137,8 @@ private synchronized void collectRunInfo() {
if (testCollection == null || testCollection.isEmpty())
return;

reportEndDate = Calendar.getInstance().getTime();

testCollection.forEach(this::endTest);

stats.refresh(testCollection);
Expand Down Expand Up @@ -164,11 +167,17 @@ private void updateReportStartTimeForManualConfigurationSetting() {
if (usesManualConfiguration) {
testCollection.forEach(test -> {
Date testStartDate = test.getStartTime();
Date testEndDate = test.getEndTime();
long testStartTime = testStartDate.getTime();
long testEndTime = testEndDate.getTime();

if (reportStartDate.getTime() > testStartTime) {
reportStartDate = testStartDate;
}

if (reportEndDate.getTime() > testEndTime) {
reportEndDate = testEndDate;
}
});
}
}
Expand Down Expand Up @@ -205,6 +214,7 @@ private synchronized void notifyReporters() {
x.setTestRunnerLogs(testRunnerLogs);
x.setStatusCount(stats);
x.setStartTime(reportStartDate);
x.setEndTime(reportEndDate);
});

reporterCollection.forEach(ExtentReporter::flush);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public ExceptionTestContextImpl getExceptionContextInfo() {
return exceptionContext;
}

@Override
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.InputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -133,8 +132,6 @@ public synchronized void flush() {

parsedTestCollection = null;

setEndTime(Calendar.getInstance().getTime());

String extentSource = null;

try {
Expand Down

0 comments on commit fd87933

Please sign in to comment.