Skip to content

Commit

Permalink
improved csv suite export (via #856)
Browse files Browse the repository at this point in the history
  • Loading branch information
msb217 authored and baev committed Dec 18, 2018
1 parent 6fcda7d commit 4845518
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import io.qameta.allure.entity.TestResult;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
* Class contains the information for the suites csv export.
Expand All @@ -16,38 +18,102 @@ public class CsvExportSuite implements Serializable {
@CsvBindByPosition(position = 0)
private final String status;

@CsvBindByName(column = "Name")
@CsvBindByName(column = "Start Time")
@CsvBindByPosition(position = 1)
private final String name;
private final String start;

@CsvBindByName(column = "Duration in ms")
@CsvBindByName(column = "Stop Time")
@CsvBindByPosition(position = 2)
private final String stop;

@CsvBindByName(column = "Duration in ms")
@CsvBindByPosition(position = 3)
private final String duration;

@CsvBindByName(column = "Parent Suite")
@CsvBindByPosition(position = 4)
private final String parentSuite;

@CsvBindByName(column = "Suite")
@CsvBindByPosition(position = 5)
private final String suite;

@CsvBindByName(column = "Sub Suite")
@CsvBindByPosition(position = 6)
private final String subSuite;

@CsvBindByName(column = "Test Class")
@CsvBindByPosition(position = 7)
private final String testClass;

@CsvBindByName(column = "Test Method")
@CsvBindByPosition(position = 8)
private final String testMethod;

@CsvBindByName(column = "Name")
@CsvBindByPosition(position = 9)
private final String name;

@CsvBindByName(column = "Description")
@CsvBindByPosition(position = 3)
private final String message;
@CsvBindByPosition(position = 10)
private final String description;

public CsvExportSuite(final TestResult result) {
final Map<String, String> resultMap = result.toMap();
this.status = result.getStatus() != null ? result.getStatus().value() : null;
this.name = result.getFullName();
this.duration = result.getTime().getDuration() != null ? result.getTime().getDuration().toString() : null;
this.message = result.getDescription();
this.start = result.getTime().getStart() != null ? new Date(result.getTime().getStart()).toString() : null;
this.stop = result.getTime().getStop() != null ? new Date(result.getTime().getStop()).toString() : null;
this.parentSuite = resultMap.getOrDefault("parentSuite", null);
this.suite = resultMap.getOrDefault("suite", null);
this.subSuite = resultMap.getOrDefault("subSuite", null);
this.testClass = resultMap.getOrDefault("testClass", null);
this.testMethod = resultMap.getOrDefault("testMethod", null);
this.name = result.getName();
this.description = result.getDescription();
}

public String getMessage() {
return message;
public String getStatus() {
return status;
}

public String getDuration() {
return duration;
}

public String getStart() {
return start;
}

public String getStop() {
return stop;
}

public String getParentSuite() {
return parentSuite;
}

public String getSuite() {
return suite;
}

public String getSubSuite() {
return subSuite;
}

public String getTestClass() {
return testClass;
}

public String getTestMethod() {
return testMethod;
}

public String getName() {
return name;
}

public String getStatus() {
return status;
public String getDescription() {
return description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,12 @@ public static Comparator<TestResult> comparingByTimeAsc() {
nullsFirst(comparing(Time::getStart, nullsFirst(naturalOrder())))
);
}

public Map<String, String> toMap() {
final Map<String, String> map = new HashMap<String, String>();
for (Label l : getLabels()) {
map.put(l.getName(), l.getValue());
}
return map;
}
}

0 comments on commit 4845518

Please sign in to comment.