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
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ private String getHistoryId(final TestCase testCase) {
return Utils.md5(testCaseLocation);
}

@SuppressWarnings("ReturnCount")
private Status translateTestCaseStatus(final Result testCaseResult) {
switch (testCaseResult.getStatus()) {
case FAILED:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.qameta.allure.test;

import io.qameta.allure.model.Label;
import io.qameta.allure.model.Status;
import io.qameta.allure.model.TestResult;

import java.util.Objects;
import java.util.function.Predicate;

/**
* @author charlie (Dmitry Baev).
*/
@SuppressWarnings({"PMD.ClassNamingConventions", "PMD.LinguisticNaming"})
public final class AllurePredicates {

private AllurePredicates() {
throw new IllegalStateException("Do not instance");
}

public static Predicate<TestResult> hasStatus(final Status status) {
return testResult -> status.equals(testResult.getStatus());
}

public static Predicate<TestResult> hasLabel(final String name, final String value) {
final Predicate<Label> labelPredicate = label -> Objects.equals(label.getName(), name)
&& Objects.equals(label.getValue(), value);

return testResult -> testResult.getLabels().stream().anyMatch(labelPredicate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static Map<String, Object> getParametersMap(final MethodSignature signatu
return params;
}

@SuppressWarnings("ReturnCount")
public static String objectToString(final Object object) {
try {
if (Objects.nonNull(object) && (object instanceof Object[])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static String processNameTemplate(final String template, final Map<String
return sb.toString();
}

@SuppressWarnings("ReturnCount")
private static Optional<String> processPattern(final String pattern, final Map<String, Object> params) {
if (pattern.isEmpty()) {
LOGGER.error("Could not process empty pattern");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public final class ResultsUtils {
public static final String ISSUE_LINK_TYPE = "issue";
public static final String TMS_LINK_TYPE = "tms";

public static final String SUITE_LABEL_NAME = "suite";
public static final String EPIC_LABEL_NAME = "epic";
public static final String FEATURE_LABEL_NAME = "feature";
public static final String STORY_LABEL_NAME = "story";
Expand All @@ -66,6 +67,9 @@ public final class ResultsUtils {
public static final String OWNER_LABEL_NAME = "owner";
public static final String HOST_LABEL_NAME = "host";
public static final String THREAD_LABEL_NAME = "thread";
public static final String TEST_METHOD_LABEL_NAME = "testMethod";
public static final String TEST_CLASS_LABEL_NAME = "testClass";
public static final String PACKAGE_LABEL_NAME = "package";

private static final Logger LOGGER = LoggerFactory.getLogger(ResultsUtils.class);
private static final String ALLURE_DESCRIPTIONS_PACKAGE = "allureDescriptions/";
Expand All @@ -77,6 +81,22 @@ private ResultsUtils() {
throw new IllegalStateException("Do not instance");
}

public static Label createSuiteLabel(final String suite) {
return new Label().setName(SUITE_LABEL_NAME).setValue(suite);
}

public static Label createTestMethodLabel(final String testMethod) {
return new Label().setName(TEST_METHOD_LABEL_NAME).setValue(testMethod);
}

public static Label createTestClassLabel(final String testClass) {
return new Label().setName(TEST_CLASS_LABEL_NAME).setValue(testClass);
}

public static Label createPackageLabel(final String packageName) {
return new Label().setName(PACKAGE_LABEL_NAME).setValue(packageName);
}

public static Label createEpicLabel(final String epic) {
return new Label().setName(EPIC_LABEL_NAME).setValue(epic);
}
Expand Down Expand Up @@ -301,6 +321,9 @@ public static void processDescription(final ClassLoader classLoader,

private static Optional<String> readResource(final ClassLoader classLoader, final String resourceName) {
try (InputStream is = classLoader.getResourceAsStream(resourceName)) {
if (Objects.isNull(is)) {
return Optional.empty();
}
final byte[] bytes = IOUtils.toByteArray(is);
return Optional.of(new String(bytes, StandardCharsets.UTF_8));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public DifferenceContext getContext() {
return context;
}

@SuppressWarnings("ReturnCount")
private String getPath(final Difference difference) {
switch (difference.getType()) {
case DIFFERENT:
Expand Down
8 changes: 6 additions & 2 deletions allure-junit-platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ val agent by configurations.creating

dependencies {
agent("org.aspectj:aspectjweaver")
compile(project(":allure-java-commons"))
compile("org.junit.jupiter:junit-jupiter-api")
compile("org.junit.platform:junit-platform-launcher")
testCompile(project(":allure-java-commons-test"))
compile(project(":allure-java-commons"))
testAnnotationProcessor(project(":allure-descriptions-javadoc"))
testCompile("io.github.glytching:junit-extensions")
testCompile("org.assertj:assertj-core")
testCompile("org.junit.jupiter:junit-jupiter-api")
testCompile("org.junit.jupiter:junit-jupiter-params")
testCompile("org.slf4j:slf4j-simple")
testCompile(project(":allure-assertj"))
testCompile(project(":allure-java-commons-test"))
testRuntime("org.junit.jupiter:junit-jupiter-engine")
}

Expand All @@ -27,6 +30,7 @@ tasks.named<Jar>("jar") {
}

tasks.named<Test>("test") {
systemProperty("junit.jupiter.execution.parallel.enabled", "false")
useJUnitPlatform()
exclude("**/features/*")
doFirst {
Expand Down
Loading