Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ body:
- allure-jsonunit
- allure-junit-platform
- allure-junit4
- allure-jupiter
- allure-jupiter-assert
- allure-junit5
- allure-junit5-assert
- allure-karate
- allure-okhttp
- allure-okhttp3
Expand Down
4 changes: 2 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
- "allure-junit4-aspect/**"

"theme:junit-platform":
- "allure-junit5/**"
- "allure-junit5-assert/**"
- "allure-jupiter/**"
- "allure-jupiter-assert/**"
- "allure-junit-platform/**"

"theme:karate":
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
- 📚 Example project — https://github.com/allure-examples?q=topic%3Ajunit4
- ✅ Generate a project in 10 seconds via Allure Start - https://allurereport.org/start/
-
## JUnit 5

- 🚀 Documentation — https://allurereport.org/docs/junit5/
- 📚 Example project — https://github.com/allure-examples?q=topic%3Ajunit5
- ✅ Generate a project in 10 seconds via Allure Start - https://allurereport.org/start/
## JUnit Jupiter (JUnit 5 and 6)

- 🚀 Documentation — https://allurereport.org/docs/junit5/
- 📚 Example project — https://github.com/allure-examples?q=topic%3Ajunit5
- ✅ Generate a project in 10 seconds via Allure Start - https://allurereport.org/start/
- 🧩 Use `io.qameta.allure:allure-jupiter` for new setups. `allure-junit5` remains available as a deprecated compatibility alias during migration.

## Cucumber JVM

Expand Down
2 changes: 2 additions & 0 deletions allure-bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ dependencies {
constraints {
rootProject.subprojects.sorted()
.forEach { api("${it.group}:${it.name}:${it.version}") }
api("io.qameta.allure:allure-junit5:${project.version}")
api("io.qameta.allure:allure-junit5-assert:${project.version}")
}
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Adding JUnit5-assert may lead to java.lang.OutOfMemoryError: Java heap space
Adding Jupiter assert may lead to java.lang.OutOfMemoryError: Java heap space

The primary artifact is now `allure-jupiter-assert`. `allure-junit5-assert` remains available as a deprecated compatibility alias during the transition.

Having a huge class path may lead to OOM, because AspectJ processes all the classes. [Link to documentation](https://www.eclipse.org/aspectj/doc/released/devguide/ltw.html)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description = "Allure Junit5 Assertions Integration"
description = "Allure Jupiter Assertions Integration"

dependencies {
api(project(":allure-junit5"))
api(project(":allure-jupiter"))
compileOnly("org.aspectj:aspectjrt")
compileOnly("org.junit.jupiter:junit-jupiter-api")
testAnnotationProcessor(project(":allure-descriptions-javadoc"))
Expand All @@ -15,7 +15,7 @@ dependencies {
tasks.jar {
manifest {
attributes(mapOf(
"Automatic-Module-Name" to "io.qameta.allure.junit5-assert"
"Automatic-Module-Name" to "io.qameta.allure.jupiterassert"
))
}
}
Expand All @@ -24,3 +24,10 @@ tasks.test {
useJUnitPlatform()
}

publishing {
publications {
create<MavenPublication>("legacyJunit5Assert") {
artifactId = "allure-junit5-assert"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.junit5assert;

import io.qameta.allure.AllureLifecycle;
import io.qameta.allure.jupiterassert.AllureJupiterAssert;

/**
* @author legionivo (Andrey Konovka).
* @deprecated use {@link AllureJupiterAssert}.
*/
@Deprecated
public class AllureJunit5Assert extends AllureJupiterAssert {

/**
* For tests only.
*
* @param allure allure lifecycle to set.
*/
public static void setLifecycle(final AllureLifecycle allure) {
AllureJupiterAssert.setLifecycle(allure);
}

public static AllureLifecycle getLifecycle() {
return AllureJupiterAssert.getLifecycle();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure.junit5assert;
package io.qameta.allure.jupiterassert;

import io.qameta.allure.Allure;
import io.qameta.allure.AllureLifecycle;
Expand Down Expand Up @@ -41,13 +41,12 @@
*/
@SuppressWarnings("all")
@Aspect
public class AllureJunit5Assert {
public class AllureJupiterAssert {

private static final Logger LOGGER = LoggerFactory.getLogger(AllureJunit5Assert.class);
private static final Logger LOGGER = LoggerFactory.getLogger(AllureJupiterAssert.class);
private StepResult stepResult;


private static InheritableThreadLocal<AllureLifecycle> lifecycle = new InheritableThreadLocal<AllureLifecycle>() {
private static final InheritableThreadLocal<AllureLifecycle> LIFECYCLE = new InheritableThreadLocal<AllureLifecycle>() {
@Override
protected AllureLifecycle initialValue() {
return Allure.getLifecycle();
Expand All @@ -69,11 +68,10 @@ public void stepStart(final JoinPoint joinPoint) {
if (joinPoint.getArgs().length > 1) {
final String uuid = UUID.randomUUID().toString();
final String assertName = joinPoint.getSignature().getName();
String name;
final String name;
if (joinPoint.getSignature().getName().equalsIgnoreCase("assertAll")) {
name = String.format("assert All in " + " \'%s\'", joinPoint.getArgs()[0].toString());
name = String.format("assert All in " + " '%s'", joinPoint.getArgs()[0].toString());
} else {

final String actual = joinPoint.getArgs().length > 0
? ObjectUtils.toString(joinPoint.getArgs()[1])
: "<?>";
Expand All @@ -83,12 +81,13 @@ public void stepStart(final JoinPoint joinPoint) {

final List<String> assertArray = Arrays.asList(assertName.split("(?=[A-Z])"));
if (assertArray.size() >= 3) {
name = String.format(assertArray.get(0) + " " + assertArray.get(1) + " \'%s\'", expected)
name = String.format(assertArray.get(0) + " " + assertArray.get(1) + " '%s'", expected)
+ " " + String.format(assertArray.stream()
.skip(2)
.collect(Collectors.joining(" ")) + " \'%s\'", actual);
.collect(Collectors.joining(" ")) + " '%s'", actual);
} else {
name = String.format(assertArray.get(0) + " \'%s\'", expected) + " " + String.format(assertArray.get(1) + " \'%s\'", actual);
name = String.format(assertArray.get(0) + " '%s'", expected)
+ " " + String.format(assertArray.get(1) + " '%s'", actual);
}
}
final StepResult result = new StepResult()
Expand All @@ -101,7 +100,7 @@ public void stepStart(final JoinPoint joinPoint) {
: "<?>";
final String uuid = UUID.randomUUID().toString();
final String assertName = joinPoint.getSignature().getName();
final String name = String.format(assertName + " \'%s\'", actual);
final String name = String.format(assertName + " '%s'", actual);

final StepResult result = new StepResult()
.setName(name)
Expand Down Expand Up @@ -129,11 +128,10 @@ public void stepStop() {
* @param allure allure lifecycle to set.
*/
public static void setLifecycle(final AllureLifecycle allure) {
lifecycle.set(allure);
LIFECYCLE.set(allure);
}

public static AllureLifecycle getLifecycle() {
return lifecycle.get();
return LIFECYCLE.get();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<aspectj>
<weaver options="-warn:none -Xlint:ignore"/>
<aspects>
<aspect name="io.qameta.allure.junit5assert.AllureJunit5Assert"/>
<aspect name="io.qameta.allure.jupiterassert.AllureJupiterAssert"/>
</aspects>
</aspectj>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.jupiterassert;

import io.qameta.allure.model.StepResult;
import io.qameta.allure.model.TestResult;
import io.qameta.allure.test.AllureResults;
import org.junit.jupiter.api.Test;

import static io.qameta.allure.test.RunUtils.runWithinTestContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

class AllureJupiterAssertTest {

@Test
void shouldHandleAssertEquals() {
final AllureResults results = runWithinTestContext(
() -> assertEquals("expectedString", "actualString"),
AllureJupiterAssert::setLifecycle
);

assertThat(results.getTestResults())
.flatExtracting(TestResult::getSteps)
.extracting(StepResult::getName)
.containsExactly("assert 'expectedString' Equals 'actualString'");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description = "Allure JUnit 5 Integration"
description = "Allure Jupiter Integration"

dependencies {
api(project(":allure-junit-platform"))
Expand All @@ -19,7 +19,7 @@ dependencies {
tasks.jar {
manifest {
attributes(mapOf(
"Automatic-Module-Name" to "io.qameta.allure.junit5"
"Automatic-Module-Name" to "io.qameta.allure.jupiter"
))
}
from("src/main/services") {
Expand All @@ -43,6 +43,9 @@ publishing {
named<MavenPublication>("maven") {
artifact(spiOffJar)
}
create<MavenPublication>("legacyJunit5") {
artifactId = "allure-junit5"
artifact(spiOffJar)
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.junit5;

import io.qameta.allure.jupiter.AllureJupiter;

/**
* @author charlie (Dmitry Baev).
* @deprecated use {@link AllureJupiter}.
*/
@Deprecated
public class AllureJunit5 extends AllureJupiter {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure.junit5;
package io.qameta.allure.jupiter;

import io.qameta.allure.Param;
import io.qameta.allure.model.Status;
Expand All @@ -27,8 +27,8 @@
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
Expand All @@ -50,12 +50,18 @@
* @author charlie (Dmitry Baev).
*/
@SuppressWarnings("MultipleStringLiterals")
public class AllureJunit5 implements InvocationInterceptor {
public class AllureJupiter implements InvocationInterceptor {

private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(AllureJupiter.class);

@Override
public void interceptTestTemplateMethod(final Invocation<Void> invocation,
final ReflectiveInvocationContext<Method> invocationContext,
final ExtensionContext extensionContext) throws Throwable {
if (!shouldHandle(extensionContext, "template", invocationContext.getExecutable())) {
invocation.proceed();
return;
}
sendParameterEvent(invocationContext, extensionContext);
invocation.proceed();
}
Expand Down Expand Up @@ -134,6 +140,10 @@ protected void processFixture(final String type,
final Invocation<Void> invocation,
final ReflectiveInvocationContext<Method> invocationContext,
final ExtensionContext extensionContext) throws Throwable {
if (!shouldHandle(extensionContext, type, invocationContext.getExecutable())) {
invocation.proceed();
return;
}
final String uuid = UUID.randomUUID().toString();
try {
extensionContext.publishReportEntry(wrap(buildStartEvent(
Expand Down Expand Up @@ -206,4 +216,18 @@ public Map<String, String> wrap(final Map<String, String> data) {
);
return res;
}

private boolean shouldHandle(final ExtensionContext extensionContext,
final String eventType,
final Method method) {
final Object marker = new Object();
final String key = String.join(":",
extensionContext.getUniqueId(),
eventType,
method.toGenericString()
);
return extensionContext.getRoot()
.getStore(NAMESPACE)
.getOrComputeIfAbsent(key, ignored -> marker) == marker;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.qameta.allure.jupiter.AllureJupiter
Loading
Loading