org.conqat.engine.index.shared.tests.ETestExecutionResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-commons Show documentation
Show all versions of teamscale-commons Show documentation
Provides common DTOs for Teamscale
/*
* Copyright (c) CQSE GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.conqat.engine.index.shared.tests;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.conqat.lib.commons.js_export.ExportToTypeScript;
/**
* The result of a test execution. The order of the test executions is important
* when determining the
* {@link #worst(ETestExecutionResult, ETestExecutionResult)}
* {@link ETestExecutionResult}. The order must be from best to worst in order
* of definition in the {@link Enum} (i.e. highest ordinal is worst
* {@link ETestExecutionResult}).
*/
@ExportToTypeScript
public enum ETestExecutionResult {
/** Test execution was successful. */
PASSED("passed"),
/** The test is currently marked as "do not execute" (e.g. JUnit @Ignore). */
IGNORED("ignored"),
/** Caused by a failing assumption. */
SKIPPED("skipped"),
/** Caused by a failing assertion. */
FAILURE("failure"),
/** Caused by an error during test execution (e.g. exception thrown). */
ERROR("error"),
/** Test execution without unambiguous result. */
INCONCLUSIVE("inconclusive");
/** Stores the readable names for the cases */
private String readableName;
/**
* To sum up all possible results in, e.g., parameter descriptions, a
* compile-time constant expression is needed. So we maintained manually a
* string representation of all possible results here.
*/
public static final String ALL_RESULTS = "PASSED, IGNORED, SKIPPED, FAILURE, ERROR";
/** The best {@link ETestExecutionResult}. */
public static final ETestExecutionResult BEST_RESULT = ETestExecutionResult.values()[0];
/** Constructor */
ETestExecutionResult(String readableName) {
this.readableName = readableName;
}
/**
* Returns the worst {@link ETestExecutionResult} between the two
* {@link ETestExecutionResult}s.
*/
public static ETestExecutionResult worst(@Nullable ETestExecutionResult resultA,
@Nullable ETestExecutionResult resultB) {
if (resultA == null) {
return resultB;
}
if (resultB == null) {
return resultA;
}
if (resultA.ordinal() < resultB.ordinal()) {
return resultB;
}
return resultA;
}
/** Returns the readableName */
public String getReadableName() {
return readableName;
}
/**
* Returns a list of all readable names (i.e. one readable name for each case)
*/
public static List getReadableNames() {
return Arrays.stream(ETestExecutionResult.values()).map(ETestExecutionResult::getReadableName)
.collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy