Skip to content

Commit

Permalink
Remove environment. Add env variables
Browse files Browse the repository at this point in the history
Removed environment.
Added env variables for TestExecutionId and TestExecutionSummary.
  • Loading branch information
MariaSales committed Nov 4, 2020
1 parent 0f98f52 commit ad3c81f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ jira_authentication = cookie/basic
> Default jira_authentication is cookie if property not provided.
The following env variables are optional, and allow to configure a specific testExecutionId and summary:

```properties
jira_testExecutionId = JIRA_ID
jira_testExecutionSummary = Expected JIRA issue summary
```

#### Add **TestCaseId:\<XrayTestKey>** tag to scenarios

```markdown
Expand All @@ -63,7 +70,8 @@ Tags: TestCaseId:PROJECT-1

#### Reuse Test Execution

In order to avoid creating a new test execution for each run, add **TestExecutionId:\<XrayTestExecutionKey>** tag to spec
In order to avoid creating a new test execution for each run, add **TestExecutionId:\<XrayTestExecutionKey>** tag to spec.
Note: TestExecutionId defined in the tag will only be used if there was none set in the env variables.

```markdown
# Spec
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/org/gauge/xray/ReportGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public final class ReportGenerator {
private ReportGenerator() {
}

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

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

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/gauge/xray/Reporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ public static void main(String[] args) {
Message message = Message.parseDelimitedFrom(socket.getInputStream());
if (message.getMessageType() == Message.MessageType.SuiteExecutionResult) {
SuiteExecutionResult result = message.getSuiteExecutionResult();
String environment = getProperty("GAUGE_ENVIRONMENT");
List<Report> reports = ReportGenerator.generate(result, environment);

String jiraTestExecutionId = getProperty("jira_testExecutionId");
String jiraTestExecutionSummary = getProperty("jiraTestExecutionSummary");

List<Report> reports = ReportGenerator.generate(result, jiraTestExecutionId, jiraTestExecutionSummary);
Gson gson = new GsonBuilder()
.disableHtmlEscaping()
.setPrettyPrinting()
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/gauge/xray/report/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ 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 @@ -169,13 +166,5 @@ public Info withTestEnvironments(List<String> testEnvironments) {
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 ad3c81f

Please sign in to comment.