Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# qase-java 4.1.18

## What's new

- Added support for external link for test runs.
- Added support for filtering test results by status.

# qase-java 4.1.17

## What's new
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.qase</groupId>
<artifactId>qase-java</artifactId>
<packaging>pom</packaging>
<version>4.1.17</version>
<version>4.1.18</version>
<modules>
<module>qase-java-commons</module>
<module>qase-api-client</module>
Expand Down
2 changes: 1 addition & 1 deletion qase-api-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>qase-java</artifactId>
<groupId>io.qase</groupId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion qase-api-v2-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.qase</groupId>
<artifactId>qase-java</artifactId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>

<artifactId>qase-api-v2-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion qase-cucumber-v3-reporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>qase-java</artifactId>
<groupId>io.qase</groupId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion qase-cucumber-v4-reporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>qase-java</artifactId>
<groupId>io.qase</groupId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion qase-cucumber-v5-reporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>qase-java</artifactId>
<groupId>io.qase</groupId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion qase-cucumber-v6-reporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>qase-java</artifactId>
<groupId>io.qase</groupId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion qase-cucumber-v7-reporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>qase-java</artifactId>
<groupId>io.qase</groupId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
13 changes: 12 additions & 1 deletion qase-java-commons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ All configuration options are listed in the table below:
| Qase test run description | `testops.run.description` | `QASE_TESTOPS_RUN_DESCRIPTION` | `QASE_TESTOPS_RUN_DESCRIPTION` | `<Framework name> automated run` | No | Any string |
| Qase test run complete | `testops.run.complete` | `QASE_TESTOPS_RUN_COMPLETE` | `QASE_TESTOPS_RUN_COMPLETE` | `True` | | `True`, `False` |
| Qase test run tags | `testops.run.tags` | `QASE_TESTOPS_RUN_TAGS` | `QASE_TESTOPS_RUN_TAGS` | undefined | No | Comma-separated strings |
| External link type for test run | `testops.run.externalLink.type` | `QASE_TESTOPS_RUN_EXTERNAL_LINK_TYPE` | `QASE_TESTOPS_RUN_EXTERNAL_LINK_TYPE` | `null` | No | `jiraCloud`, `jiraServer` |
| External link URL for test run | `testops.run.externalLink.link` | `QASE_TESTOPS_RUN_EXTERNAL_LINK` | `QASE_TESTOPS_RUN_EXTERNAL_LINK` | `null` | No | Any valid URL |
| Qase test run configurations | `testops.run.configurations` | `QASE_TESTOPS_RUN_CONFIGURATIONS` | `QASE_TESTOPS_RUN_CONFIGURATIONS` | undefined | No | Comma-separated key=value pairs |
| Qase test run configurations create if not exists | `testops.run.configurations.createIfNotExists` | `QASE_TESTOPS_CONFIGURATIONS_CREATE_IF_NOT_EXISTS` | `QASE_TESTOPS_CONFIGURATIONS_CREATE_IF_NOT_EXISTS` | `False` | No | `True`, `False` |
| Qase test plan ID | `testops.plan.id` | `QASE_TESTOPS_PLAN_ID` | `QASE_TESTOPS_PLAN_ID` | undefined | No | Any integer |
| Size of batch for sending test results | `testops.batch.size` | `QASE_TESTOPS_BATCH_SIZE` | `QASE_TESTOPS_BATCH_SIZE` | `200` | No | Any integer |
| Enable defects for failed test cases | `testops.defect` | `QASE_TESTOPS_DEFECT` | `QASE_TESTOPS_DEFECT` | `False` | No | `True`, `False` |
| Filter test results by status (exclude specified statuses) | `testops.statusFilter` | `QASE_TESTOPS_STATUS_FILTER` | `QASE_TESTOPS_STATUS_FILTER` | `[]` | No | Comma-separated status names |

### Example `qase.config.json` config:

Expand Down Expand Up @@ -98,13 +101,21 @@ All configuration options are listed in the table below:
}
],
"createIfNotExists": true
},
"externalLink": {
"type": "jiraCloud",
"link": "PROJ-123"
}
},
"defect": false,
"project": "<project_code>",
"batch": {
"size": 100
}
},
"statusFilter": [
"SKIPPED",
"INVALID"
]
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion qase-java-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.qase</groupId>
<artifactId>qase-java</artifactId>
<version>4.1.17</version>
<version>4.1.18</version>
</parent>

<artifactId>qase-java-commons</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public interface ApiClient {
void uploadResults(Long runId, List<TestResult> results) throws QaseException;

List<Long> getTestCaseIdsForExecution() throws QaseException;

void updateExternalIssue(Long runId) throws QaseException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.qase.client.v1.api.PlansApi;
import io.qase.client.v1.api.RunsApi;
import io.qase.client.v1.models.*;
import io.qase.commons.config.ExternalLinkType;
import io.qase.commons.QaseException;
import io.qase.commons.config.ConfigurationValue;
import io.qase.commons.config.QaseConfig;
Expand Down Expand Up @@ -119,6 +120,35 @@ public void completeTestRun(Long runId) throws QaseException {
logger.info("Test run link: %srun/%s/dashboard/%d", this.url, this.config.testops.project, runId);
}

@Override
public void updateExternalIssue(Long runId) throws QaseException {
if (this.config.testops.run.externalLink == null) {
return;
}

try {
// Map our enum values to API enum values
RunexternalIssues.TypeEnum apiType = this.config.testops.run.externalLink.getType() == ExternalLinkType.JIRA_CLOUD
? RunexternalIssues.TypeEnum.CLOUD
: RunexternalIssues.TypeEnum.SERVER;

RunexternalIssuesLinksInner link = new RunexternalIssuesLinksInner()
.runId(runId)
.externalIssue(this.config.testops.run.externalLink.getLink());

RunexternalIssues externalIssues = new RunexternalIssues()
.type(apiType)
.links(Collections.singletonList(link));

new RunsApi(client)
.runUpdateExternalIssue(this.config.testops.project, externalIssues);

logger.info("External issue link updated for run %d: %s", runId, this.config.testops.run.externalLink.getLink());
} catch (ApiException e) {
throw new QaseException("Failed to update external issue: " + e.getResponseBody(), e.getCause());
}
}

@Override
public void uploadResults(Long runId, List<TestResult> results) throws QaseException {
throw new NotImplementedException("Use ApiClientV2 for uploading results");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public void completeTestRun(Long runId) throws QaseException {
this.apiClientV1.completeTestRun(runId);
}

@Override
public void updateExternalIssue(Long runId) throws QaseException {
this.apiClientV1.updateExternalIssue(runId);
}

@Override
public void uploadResults(Long runId, List<TestResult> results) throws QaseException {
List<ResultCreate> models = results.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ private static QaseConfig loadFromEnv(QaseConfig qaseConfig) {
qaseConfig.testops.run.id = getIntEnv("QASE_TESTOPS_RUN_ID", qaseConfig.testops.run.id);
qaseConfig.testops.run.complete = getBooleanEnv("QASE_TESTOPS_RUN_COMPLETE", qaseConfig.testops.run.complete);
qaseConfig.testops.run.tags = getEnvArray("QASE_TESTOPS_RUN_TAGS", qaseConfig.testops.run.tags);
qaseConfig.testops.run.externalLink = getExternalLinkEnv("QASE_TESTOPS_RUN_EXTERNAL_LINK_TYPE", "QASE_TESTOPS_RUN_EXTERNAL_LINK", qaseConfig.testops.run.externalLink);
qaseConfig.testops.plan.id = getIntEnv("QASE_TESTOPS_PLAN_ID", qaseConfig.testops.plan.id);
qaseConfig.testops.batch.setSize(getIntEnv("QASE_TESTOPS_BATCH_SIZE", qaseConfig.testops.batch.getSize()));
qaseConfig.testops.statusFilter = Arrays.asList(getEnvArray("QASE_TESTOPS_STATUS_FILTER", qaseConfig.testops.statusFilter.toArray(new String[0])));
qaseConfig.report.setDriver(getEnv("QASE_REPORT_DRIVER", qaseConfig.report.getDriver()));
qaseConfig.report.connection.local
.setFormat(getEnv("QASE_REPORT_CONNECTION_FORMAT", qaseConfig.report.connection.local.getFormat()));
Expand Down Expand Up @@ -109,8 +111,10 @@ private static QaseConfig loadFromSystemProperties(QaseConfig qaseConfig) {
qaseConfig.testops.run.complete = getBooleanProperty("QASE_TESTOPS_RUN_COMPLETE",
qaseConfig.testops.run.complete);
qaseConfig.testops.run.tags = getPropertyArray("QASE_TESTOPS_RUN_TAGS", qaseConfig.testops.run.tags);
qaseConfig.testops.run.externalLink = getExternalLinkProperty("QASE_TESTOPS_RUN_EXTERNAL_LINK_TYPE", "QASE_TESTOPS_RUN_EXTERNAL_LINK", qaseConfig.testops.run.externalLink);
qaseConfig.testops.plan.id = getIntProperty("QASE_TESTOPS_PLAN_ID", qaseConfig.testops.plan.id);
qaseConfig.testops.batch.setSize(getIntProperty("QASE_TESTOPS_BATCH_SIZE", qaseConfig.testops.batch.getSize()));
qaseConfig.testops.statusFilter = Arrays.asList(getPropertyArray("QASE_TESTOPS_STATUS_FILTER", qaseConfig.testops.statusFilter.toArray(new String[0])));

qaseConfig.report.setDriver(getProperty("QASE_REPORT_DRIVER", qaseConfig.report.getDriver()));
qaseConfig.report.connection.local.setFormat(
Expand Down Expand Up @@ -204,6 +208,38 @@ private static ConfigurationValue parseConfigurationValue(String configString) {
return new ConfigurationValue(parts[0].trim(), parts[1].trim());
}

private static TestOpsExternalLinkType getExternalLinkEnv(String typeKey, String linkKey, TestOpsExternalLinkType defaultValue) {
String typeValue = System.getenv(typeKey);
String linkValue = System.getenv(linkKey);

if (typeValue == null || linkValue == null) {
return defaultValue;
}

try {
return new TestOpsExternalLinkType(ExternalLinkType.fromValue(typeValue), linkValue);
} catch (IllegalArgumentException e) {
logger.error("Invalid external link type: %s", typeValue);
return defaultValue;
}
}

private static TestOpsExternalLinkType getExternalLinkProperty(String typeKey, String linkKey, TestOpsExternalLinkType defaultValue) {
String typeValue = System.getProperty(typeKey);
String linkValue = System.getProperty(linkKey);

if (typeValue == null || linkValue == null) {
return defaultValue;
}

try {
return new TestOpsExternalLinkType(ExternalLinkType.fromValue(typeValue), linkValue);
} catch (IllegalArgumentException e) {
logger.error("Invalid external link type: %s", typeValue);
return defaultValue;
}
}

private static void applyJsonConfig(QaseConfig qaseConfig, JSONObject fileConfig) {
if (fileConfig.has("mode")) {
qaseConfig.setMode(fileConfig.getString("mode"));
Expand Down Expand Up @@ -291,6 +327,18 @@ private static void applyJsonConfig(QaseConfig qaseConfig, JSONObject fileConfig
if (run.has("complete")) {
qaseConfig.testops.run.complete = run.getBoolean("complete");
}

if (run.has("externalLink")) {
JSONObject externalLinkObj = run.getJSONObject("externalLink");
TestOpsExternalLinkType externalLink = new TestOpsExternalLinkType();
if (externalLinkObj.has("type")) {
externalLink.setType(ExternalLinkType.fromValue(externalLinkObj.getString("type")));
}
if (externalLinkObj.has("link")) {
externalLink.setLink(externalLinkObj.getString("link"));
}
qaseConfig.testops.run.externalLink = externalLink;
}
}

if (testOps.has("plan")) {
Expand All @@ -308,6 +356,14 @@ private static void applyJsonConfig(QaseConfig qaseConfig, JSONObject fileConfig
qaseConfig.testops.batch.setSize(batch.getInt("size"));
}
}

if (testOps.has("statusFilter")) {
qaseConfig.testops.statusFilter.clear();
JSONArray statusFilterArray = testOps.getJSONArray("statusFilter");
for (int i = 0; i < statusFilterArray.length(); i++) {
qaseConfig.testops.statusFilter.add(statusFilterArray.getString(i));
}
}
}

if (fileConfig.has("report")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.qase.commons.config;

/**
* External link types for test runs
*/
public enum ExternalLinkType {
JIRA_CLOUD("jiraCloud"),
JIRA_SERVER("jiraServer");

private final String value;

ExternalLinkType(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public static ExternalLinkType fromValue(String value) {
for (ExternalLinkType type : values()) {
if (type.value.equals(value)) {
return type;
}
}
throw new IllegalArgumentException("Unknown external link type: " + value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public class RunConfig {
public boolean complete = true;
public Integer id = 0;
public String[] tags = {};
public TestOpsExternalLinkType externalLink;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.qase.commons.config;

/**
* External link configuration for test runs
*/
public class TestOpsExternalLinkType {
private ExternalLinkType type;
private String link;

public TestOpsExternalLinkType() {
}

public TestOpsExternalLinkType(ExternalLinkType type, String link) {
this.type = type;
this.link = link;
}

public ExternalLinkType getType() {
return type;
}

public void setType(ExternalLinkType type) {
this.type = type;
}

public String getLink() {
return link;
}

public void setLink(String link) {
this.link = link;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.qase.commons.config;

import java.util.ArrayList;
import java.util.List;

public class TestopsConfig {
public String project = "";
public boolean defect = false;
Expand All @@ -8,6 +11,7 @@ public class TestopsConfig {
public PlanConfig plan;
public BatchConfig batch;
public ConfigurationsConfig configurations;
public List<String> statusFilter = new ArrayList<>();

public TestopsConfig() {
this.api = new ApiConfig();
Expand Down
Loading