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 @@ -141,6 +141,8 @@ public class AllureJunitPlatform implements TestExecutionListener {

private static final boolean HAS_CUCUMBERJVM7_IN_CLASSPATH = isClassAvailableOnClasspath("io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm");

private static final boolean HAS_CUCUMBERJVM8_IN_CLASSPATH = isClassAvailableOnClasspath("io.qameta.allure.cucumber8jvm.AllureCucumber8Jvm");

private static final boolean HAS_KARATE_IN_CLASSPATH = isClassAvailableOnClasspath("io.qameta.allure.karate.AllureKarate");

private static final String ENGINE_SPOCK2 = "spock";
Expand Down Expand Up @@ -228,10 +230,21 @@ private boolean shouldSkipReportingFor(final TestIdentifier testIdentifier) {
final String engine = maybeEngine.get();

return HAS_SPOCK2_IN_CLASSPATH && ENGINE_SPOCK2.equals(engine)
|| HAS_CUCUMBERJVM7_IN_CLASSPATH && ENGINE_CUCUMBER.equals(engine)
|| shouldSkipCucumberEngine(engine)
|| HAS_KARATE_IN_CLASSPATH && isKarateTest(testIdentifier);
}

/**
* Returns whether reporting should defer to a dedicated Cucumber JVM Allure adapter for the given engine id.
*
* @param engine the JUnit Platform engine id
* @return {@code true} when a Cucumber 7 or Cucumber 8 Allure adapter is present and {@code engine} is cucumber
*/
static boolean shouldSkipCucumberEngine(final String engine) {
return (HAS_CUCUMBERJVM7_IN_CLASSPATH || HAS_CUCUMBERJVM8_IN_CLASSPATH)
&& ENGINE_CUCUMBER.equals(engine);
}

private boolean isKarateTest(final TestIdentifier testIdentifier) {
return getParents(testIdentifier).stream()
.map(TestIdentifier::getSource)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.cucumber8jvm;

/**
* Classpath marker that represents the dedicated Cucumber 8 adapter in JUnit Platform integration tests.
*/
public final class AllureCucumber8Jvm {

private AllureCucumber8Jvm() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,18 @@ void shouldProcessDynamicTests() {
.containsExactlyInAnyOrder("testA", "testB", "testC");
}

/**
* Ensures Cucumber scenarios stay with the dedicated Cucumber 8 adapter when both that adapter and the
* JUnit Platform listener are present.
*/
@Test
@Issue("1497")
@Description
void shouldSkipCucumberEngineWhenAllureCucumber8IsPresent() {
assertThat(AllureJunitPlatform.shouldSkipCucumberEngine("cucumber")).isTrue();
assertThat(AllureJunitPlatform.shouldSkipCucumberEngine("junit-jupiter")).isFalse();
}

/**
* Ensures the dedicated Karate adapter remains the only reporter for Karate scenarios while ordinary Jupiter
* tests from the same class are still reported by the JUnit Platform integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public class AllureJunit4 extends RunListener {

private static final boolean HAS_CUCUMBERJVM7_IN_CLASSPATH = isClassAvailableOnClasspath("io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm");

private static final boolean HAS_CUCUMBERJVM8_IN_CLASSPATH = isClassAvailableOnClasspath("io.qameta.allure.cucumber8jvm.AllureCucumber8Jvm");

/**
* The method name JUnit 4 gives the synthetic test it reports when a runner cannot be built for a class.
*/
Expand Down Expand Up @@ -448,7 +450,8 @@ private static boolean isInitializationError(final Description description) {
}

private boolean shouldIgnore(final Description description) {
return HAS_CUCUMBERJVM7_IN_CLASSPATH && AllureJunit4Utils.isCucumberTest(description);
return (HAS_CUCUMBERJVM7_IN_CLASSPATH || HAS_CUCUMBERJVM8_IN_CLASSPATH)
&& AllureJunit4Utils.isCucumberTest(description);
}

private static boolean isClassAvailableOnClasspath(final String clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public class AllureTestNg

private static final boolean HAS_CUCUMBERJVM7_IN_CLASSPATH = isClassAvailableOnClasspath("io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm");

private static final boolean HAS_CUCUMBERJVM8_IN_CLASSPATH = isClassAvailableOnClasspath("io.qameta.allure.cucumber8jvm.AllureCucumber8Jvm");

private static final boolean HAS_LISTENER_COMPARATOR = isClassAvailableOnClasspath("org.testng.ListenerComparator");

/**
Expand Down Expand Up @@ -504,7 +506,7 @@ protected boolean shouldSkipReportingFor(final ITestResult testResult) {
}

final Set<String> groupsSet = new HashSet<>(Arrays.asList(groups));
return HAS_CUCUMBERJVM7_IN_CLASSPATH && groupsSet.contains("cucumber");
return (HAS_CUCUMBERJVM7_IN_CLASSPATH || HAS_CUCUMBERJVM8_IN_CLASSPATH) && groupsSet.contains("cucumber");
}

protected void startTest(final ITestResult testResult,
Expand Down
Loading