Skip to content
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ Allure.step("Create order", () -> {

For HTTP clients, browser tools, assertion libraries, and other integrations, add the matching module from the catalog above. Each module README shows the registration snippet for that tool.

## Muted Test Execution

See [Skipping muted tests](docs/muted-tests.md) for test-plan configuration, supported runners, and
skipped-result versus discovery-exclusion behavior.

## Resources

- [Allure Report documentation](https://allurereport.org/docs/)
5 changes: 5 additions & 0 deletions allure-citrus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ Maven, with `allure-bom` imported in dependency management:

Register `io.qameta.allure.citrus.AllureCitrus` with Citrus as a test, test suite, and test action listener. The listener translates Citrus suite, test case, and action events into Allure tests and steps.

## Muted Tests

Muted-test execution skipping is not supported through this listener alone; its callbacks occur too late for a safe execution veto.
See [Skipping muted tests](../docs/muted-tests.md) for plan configuration, matching, and lifecycle limits.

## Report Output

- Citrus test cases and suite lifecycle.
Expand Down
5 changes: 5 additions & 0 deletions allure-cucumber7-jvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Register the plugin with Cucumber:

You can also pass the plugin through your Cucumber runner or build tool configuration.

## Muted Tests

An automatically discovered backend skips muted scenarios and retains skipped-and-muted results.
See [Skipping muted tests](../docs/muted-tests.md) for plan configuration, matching, and lifecycle limits.

## Report Output

- Features, scenarios, scenario outlines, examples, hooks, and steps.
Expand Down
14 changes: 14 additions & 0 deletions allure-cucumber7-jvm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ dependencies {
api(project(":allure-java-commons"))
compileOnly(platform("io.cucumber:cucumber-bom:$cucumberVersion"))
compileOnly("io.cucumber:cucumber-plugin")
compileOnly("io.cucumber:cucumber-core")
implementation("org.opentest4j:opentest4j:1.3.0")
compileOnly("io.cucumber:gherkin")
testImplementation("commons-io:commons-io")
testImplementation(platform("io.cucumber:cucumber-bom:$cucumberVersion"))
Expand All @@ -26,9 +28,16 @@ dependencies {
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

tasks.processResources {
from("src/main/services") {
into("META-INF/services")
}
}

tasks.test {
useJUnitPlatform()
systemProperty("allure.test.cucumber.version", cucumberVersion)
systemProperty("allure.test.runtime.classpath", sourceSets.test.get().runtimeClasspath.asPath)
}

val minimumCucumberTestRuntimeClasspath = configurations.testRuntimeClasspath.get().copyRecursive().apply {
Expand All @@ -55,9 +64,14 @@ val cucumber7MinimumVersionTest = tasks.register<Test>("cucumber7MinimumVersionT
)
}

filter {
includeTestsMatching("io.qameta.allure.cucumber7jvm.AllureMutedExecutionTest")
}

val standardTest = tasks.test.get()
systemProperties(standardTest.systemProperties)
systemProperty("allure.test.cucumber.version", minimumCucumberVersion)
systemProperty("allure.test.runtime.classpath", classpath.asPath)
jvmArgs = standardTest.jvmArgs
maxHeapSize = standardTest.maxHeapSize
maxParallelForks = standardTest.maxParallelForks
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2016-2026 Qameta Software Inc
*
* 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 io.qameta.allure.cucumber7jvm;

import io.cucumber.core.backend.Backend;
import io.cucumber.core.backend.BackendProviderService;
import io.cucumber.core.backend.Container;
import io.cucumber.core.backend.Glue;
import io.cucumber.core.backend.HookDefinition;
import io.cucumber.core.backend.Lookup;
import io.cucumber.core.backend.Snippet;
import io.cucumber.core.backend.TestCaseState;
import org.opentest4j.TestAbortedException;

import java.net.URI;
import java.util.List;
import java.util.function.Supplier;

/**
* Automatically installs the native pre-scenario muted-test guard.
*/
public class AllureBackendProvider implements BackendProviderService {

@Override
public Backend create(final Lookup lookup, final Container container,
final Supplier<ClassLoader> classLoader) {
return new MutedBackend();
}

private static final class MutedBackend implements Backend {

private final AllureTestPlan plan = new AllureTestPlan();

@Override
public void loadGlue(final Glue glue, final List<URI> gluePaths) {
if (!plan.hasExcludedTests()) {
return;
}
glue.addBeforeHook(new HookDefinition() {
@Override
public void execute(final TestCaseState state) {
if (plan.isMuted(state.getSourceTagNames(), state.getUri(), state.getLine())) {
throw new TestAbortedException("Skipped by Allure test plan");
}
}

@Override
public String getTagExpression() {
return "";
}

@Override
public int getOrder() {
return Integer.MIN_VALUE;
}

@Override
public boolean isDefinedAt(final StackTraceElement element) {
return false;
}

@Override
public String getLocation() {
return AllureBackendProvider.class.getName();
}
});
}

@Override
public void buildWorld() {
// The hook requires no scenario-scoped world.
}

@Override
public void disposeWorld() {
// The hook owns no scenario resources.
}

@Override
public Snippet getSnippet() {
// Reporting backends do not supply step-definition snippets.
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
Expand Down Expand Up @@ -119,7 +118,7 @@ public class AllureCucumber7Jvm implements ConcurrentEventListener {
private final Map<UUID, String> hookStepContainerUuid = new ConcurrentHashMap<>();

private static final String TEXT_PLAIN = "text/plain";
private static final String CUCUMBER_WORKING_DIR = Paths.get("").toUri().getSchemeSpecificPart();
private final AllureTestPlan testPlan = new AllureTestPlan();

/**
* Creates an Allure cucumber7 jvm with default configuration.
Expand Down Expand Up @@ -260,7 +259,11 @@ private void handleTestCaseFinished(final TestCaseFinished event) {
final TagParser tagParser = new TagParser(feature, testCase);
statusDetails
.setFlaky(tagParser.isFlaky())
.setMuted(tagParser.isMuted())
.setMuted(
tagParser.isMuted() || testPlan.isMuted(
testCase.getTags(), testCase.getUri(), testCase.getLocation().getLine()
)
)
.setKnown(tagParser.isKnown());

final AllureExternalKey testKey = testKey(uuid);
Expand Down Expand Up @@ -398,11 +401,7 @@ private String getTestCaseId(final TestCase testCase) {
}

private String getTestCaseUri(final TestCase testCase) {
final String testCaseUri = testCase.getUri().getSchemeSpecificPart();
if (testCaseUri.startsWith(CUCUMBER_WORKING_DIR)) {
return testCaseUri.substring(CUCUMBER_WORKING_DIR.length());
}
return testCaseUri;
return ScenarioUtils.scenarioUri(testCase.getUri());
}

private Status translateTestCaseStatus(final Result testCaseResult) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2016-2026 Qameta Software Inc
*
* 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 io.qameta.allure.cucumber7jvm;

import io.qameta.allure.testfilter.FileTestPlanSupplier;
import io.qameta.allure.testfilter.TestPlan;
import io.qameta.allure.testfilter.TestPlanV1_0;

import java.net.URI;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Test-plan muting decisions using the scenario's reporting identity.
*/
final class AllureTestPlan {

private static final Pattern ALLURE_ID = Pattern.compile("^@allure\\.id[:=](.+)$");

private final TestPlan plan = new FileTestPlanSupplier().supply().orElse(null);

boolean hasExcludedTests() {
return plan instanceof TestPlanV1_0
&& ((TestPlanV1_0) plan).getExcludedTests() != null
&& !((TestPlanV1_0) plan).getExcludedTests().isEmpty();
}

boolean isMuted(final Collection<String> tags, final URI uri, final int line) {
if (!(plan instanceof TestPlanV1_0)) {
return false;
}
final TestPlanV1_0 knownPlan = (TestPlanV1_0) plan;
final String selector = ScenarioUtils.scenarioUri(uri) + ":" + line;
return knownPlan.isMuted(null, selector) || tags.stream()
.map(ALLURE_ID::matcher)
.filter(Matcher::matches)
.anyMatch(matcher -> knownPlan.isMuted(matcher.group(1), selector));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2016-2026 Qameta Software Inc
*
* 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 io.qameta.allure.cucumber7jvm;

import java.net.URI;
import java.nio.file.Paths;

/**
* Shared scenario identities for execution and reporting.
*/
final class ScenarioUtils {

private static final String WORKING_DIRECTORY = Paths.get("").toUri().getSchemeSpecificPart();

private ScenarioUtils() {
}

static String scenarioUri(final URI uri) {
final String path = uri.getSchemeSpecificPart();
return path.startsWith(WORKING_DIRECTORY) ? path.substring(WORKING_DIRECTORY.length()) : path;
}
}
4 changes: 4 additions & 0 deletions allure-cucumber7-jvm/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
module io.qameta.allure.cucumber7jvm {
requires transitive io.qameta.allure.commons;
requires io.cucumber.plugin;
requires io.cucumber.core;
requires org.opentest4j;
requires io.cucumber.gherkin;
requires io.cucumber.messages;
requires org.slf4j;

exports io.qameta.allure.cucumber7jvm;

provides io.cucumber.core.backend.BackendProviderService with io.qameta.allure.cucumber7jvm.AllureBackendProvider;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.qameta.allure.cucumber7jvm.AllureBackendProvider
Loading