Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed empty string as a test case status to ignore push to tcm #73

Open
wants to merge 1 commit into
base: blocked-status
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,17 @@ private static void normalizeTcmTestCaseStatus(ReportingConfiguration.TcmConfigu
String onSkip = testCaseStatus.getOnSkip();
String onBlock = testCaseStatus.getOnBlock();

if (onPass != null && onPass.trim().isEmpty()) {
testCaseStatus.setOnPass(null);
if (onPass != null) {
testCaseStatus.setOnPass(onPass.trim());
}
if (onFail != null && onFail.trim().isEmpty()) {
testCaseStatus.setOnFail(null);
if (onFail != null) {
testCaseStatus.setOnFail(onFail.trim());
}
if (onSkip != null && onSkip.trim().isEmpty()) {
testCaseStatus.setOnSkip(null);
if (onSkip != null) {
testCaseStatus.setOnSkip(onSkip.trim());
}
if (onBlock != null && onBlock.trim().isEmpty()) {
testCaseStatus.setOnBlock(null);
if (onBlock != null) {
testCaseStatus.setOnBlock(onBlock.trim());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void setTestCaseKey(String testCaseKey) {
*
* @param testCaseKey key of the test case
* @param resultStatus name of the status to be set for the test case
* @see SystemTestCaseStatus
* @throws NullPointerException if {@code resultStatus} is null
* @see SystemTestCaseStatus
*/
public static void setTestCaseStatus(String testCaseKey, String resultStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -37,6 +38,9 @@ static TestCasesRegistry getInstance() {
return InstanceHolder.INSTANCE;
}

// used when no status is set, since "" is a status that can be explicitly set.
// push to tcm is disabled for test cases with "" status
private static final String UNSET_STATUS = "<unset>";
private static final Map<TcmType, String> TCM_TYPE_TO_LABEL_KEY = new EnumMap<>(TcmType.class);

static {
Expand All @@ -58,12 +62,14 @@ void addTestCasesToCurrentTest(TcmType tcmType, Collection<String> testCaseIds)
.filter(testCaseId -> !testCaseIdToStatus.containsKey(testCaseId))
.forEach(testCaseId -> {
Label.attachToTest(TCM_TYPE_TO_LABEL_KEY.get(tcmType), testCaseId);
testCaseIdToStatus.put(testCaseId, "");
testCaseIdToStatus.put(testCaseId, UNSET_STATUS);
});
});
}

void setCurrentTestTestCaseStatus(TcmType tcmType, String testCaseId, String status) {
Objects.requireNonNull(status, "Status cannot be null.");

RunContext.getCurrentTest()
.map(TestDescriptor::getZebrunnerId)
.ifPresent(testId -> {
Expand All @@ -85,7 +91,7 @@ void setExplicitStatusesOnCurrentTestPass() {
.ifPresent(test -> {
Long testId = test.getZebrunnerId();
String passStatus = this.getOnPassStatus(test);
if (passStatus != null && !passStatus.isEmpty()) {
if (passStatus != null) {
this.setCaseStatusesIfThereIsNoExplicit(testId, passStatus);
}
testIdToTcmTypeToTestCaseIdToStatus.remove(testId);
Expand All @@ -97,7 +103,7 @@ void setExplicitStatusesOnCurrentTestFail() {
.ifPresent(test -> {
Long testId = test.getZebrunnerId();
String failStatus = this.getOnFailStatus(test);
if (failStatus != null && !failStatus.isEmpty()) {
if (failStatus != null) {
this.setCaseStatusesIfThereIsNoExplicit(testId, failStatus);
}
testIdToTcmTypeToTestCaseIdToStatus.remove(testId);
Expand All @@ -109,7 +115,7 @@ void setExplicitStatusesOnCurrentTestSkip() {
.ifPresent(test -> {
Long testId = test.getZebrunnerId();
String skipStatus = this.getOnSkipStatus(test);
if (skipStatus != null && !skipStatus.isEmpty()) {
if (skipStatus != null) {
this.setCaseStatusesIfThereIsNoExplicit(testId, skipStatus);
}
testIdToTcmTypeToTestCaseIdToStatus.remove(testId);
Expand All @@ -121,7 +127,7 @@ void setExplicitStatusesOnCurrentTestBlock() {
.ifPresent(test -> {
Long testId = test.getZebrunnerId();
String blockStatus = this.getOnBlockStatus(test);
if (blockStatus != null && !blockStatus.isEmpty()) {
if (blockStatus != null) {
this.setCaseStatusesIfThereIsNoExplicit(testId, blockStatus);
}
testIdToTcmTypeToTestCaseIdToStatus.remove(testId);
Expand All @@ -133,7 +139,7 @@ private void setCaseStatusesIfThereIsNoExplicit(Long testId, String status) {
testIdToTcmTypeToTestCaseIdToStatus.computeIfAbsent(testId, $ -> new ConcurrentHashMap<>())
.forEach((tcmType, testCaseIdToStatus) ->
testCaseIdToStatus.forEach((testCaseId, explicitStatus) -> {
if (explicitStatus.isEmpty()) {
if (UNSET_STATUS.equals(explicitStatus)) {
results.add(new TestCaseResult(tcmType, testCaseId, status));
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public static void setTestCaseId(String testCaseId) {
*
* @param testCaseId TestRail id of the test case. Can be either a regular number or a number with the letter 'C' at the begging.
* @param resultStatus system name (not labels!) of the status to be set for the test case
* @throws NullPointerException if {@code resultStatus} is null
* @see SystemTestCaseStatus
*/
public static void setTestCaseStatus(String testCaseId, String resultStatus) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/zebrunner/agent/core/registrar/Xray.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static void setTestKey(String testKey) {
*
* @param testKey key of the Xray test
* @param resultStatus name of the status to be set for the test
* @throws NullPointerException if {@code resultStatus} is null
* @see SystemTestStatus.Cloud
* @see SystemTestStatus.Server
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static void setTestCaseKey(String testCaseKey) {
*
* @param testCaseKey key of the Zephyr test case
* @param resultStatus name of the status to be set for the test case
* @throws NullPointerException if {@code resultStatus} is null
* @see Scale.SystemTestCaseStatus.Cloud
* @see Squad.SystemTestCaseStatus.Cloud
*/
Expand Down