Skip to content

Commit

Permalink
Add environment to report
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaSales committed Nov 2, 2020
1 parent ffcd09f commit 0f98f52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/gauge/xray/ReportGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public final class ReportGenerator {
private ReportGenerator() {
}

public static List<Report> generate(Messages.SuiteExecutionResult suite) {
public static List<Report> generate(Messages.SuiteExecutionResult suite, String environment) {
List<Report> reports = new ArrayList();
for (Spec.ProtoSpecResult spec : suite.getSuiteResult().getSpecResultsList()) {
Report report = new Report();
report.setInfo(createInfo(suite.getSuiteResult()));
report.setInfo(createInfo(suite.getSuiteResult(), environment));
report.setTestExecutionKey(getTestExecutionKey(spec));
for (Spec.ProtoItem scenario : spec.getProtoSpec().getItemsList()) {
Test test = createTest(scenario);
Expand Down Expand Up @@ -61,10 +61,11 @@ private static Test createTest(Spec.ProtoItem scenario) {
return test;
}

private static Info createInfo(Spec.ProtoSuiteResult spec) {
private static Info createInfo(Spec.ProtoSuiteResult spec, String environment) {
Info info = new Info();
info.setSummary(spec.getProjectName());
info.setTestEnvironments(Arrays.asList(spec.getEnvironment().split(",")));
info.setEnvironment(environment);
return info;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/gauge/xray/Reporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public static void main(String[] args) {
Message message = Message.parseDelimitedFrom(socket.getInputStream());
if (message.getMessageType() == Message.MessageType.SuiteExecutionResult) {
SuiteExecutionResult result = message.getSuiteExecutionResult();
List<Report> reports = ReportGenerator.generate(result);
String environment = getProperty("GAUGE_ENVIRONMENT");
List<Report> reports = ReportGenerator.generate(result, environment);
Gson gson = new GsonBuilder()
.disableHtmlEscaping()
.setPrettyPrinting()
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/gauge/xray/report/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class Info {
@SerializedName("testEnvironments")
@Expose
private List<String> testEnvironments = new ArrayList();
@SerializedName("environment")
@Expose
private String environment;

public String getProject() {
return project;
Expand Down Expand Up @@ -167,5 +170,12 @@ public void addTestEnvironments(String testEnvironment) {
this.testEnvironments.add(testEnvironment);
}

public void setEnvironment(String environment) {
this.environment = environment;
}

public String getEnvironment() {
return environment;
}

}

0 comments on commit 0f98f52

Please sign in to comment.