Skip to content

Commit 20120af

Browse files
authored
assertj: add support for interface based assertions (via allure-framework#742)
1 parent be4d5ff commit 20120af

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,11 @@ protected AllureLifecycle initialValue() {
5555
}
5656
};
5757

58-
@Pointcut("execution(public org.assertj.core.api.AbstractAssert.new(..))")
58+
@Pointcut("execution(!private org.assertj.core.api.AbstractAssert.new(..))")
5959
public void anyAssertCreation() {
6060
//pointcut body, should be empty
6161
}
6262

63-
@Pointcut("execution(public * org.assertj.core.api.AssertionsForClassTypes.*(..))")
64-
public void anyAssertCreation2() {
65-
//pointcut body, should be empty
66-
}
67-
6863
@Pointcut("execution(* org.assertj.core.api.AssertJProxySetup.*(..))")
6964
public void proxyMethod() {
7065
//pointcut body, should be empty
@@ -75,7 +70,7 @@ public void anyAssert() {
7570
//pointcut body, should be empty
7671
}
7772

78-
@After("anyAssertCreation() || anyAssertCreation2()")
73+
@After("anyAssertCreation()")
7974
public void logAssertCreation(final JoinPoint joinPoint) {
8075
final String actual = joinPoint.getArgs().length > 0
8176
? ObjectUtils.toString(joinPoint.getArgs()[0])

allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.jupiter.api.Test;
2424

2525
import java.nio.charset.StandardCharsets;
26+
import java.util.Arrays;
2627

2728
import static io.qameta.allure.test.RunUtils.runWithinTestContext;
2829
import static org.assertj.core.api.Assertions.assertThat;
@@ -87,6 +88,23 @@ void shouldHandleByteArrayObject() {
8788
);
8889
}
8990

91+
@AllureFeatures.Steps
92+
@Test
93+
void shouldHandleCollections() {
94+
final AllureResults results = runWithinTestContext(() -> {
95+
assertThat(Arrays.asList("a", "b"))
96+
.containsExactly("a", "b");
97+
}, AllureAspectJ::setLifecycle);
98+
99+
assertThat(results.getTestResults())
100+
.flatExtracting(TestResult::getSteps)
101+
.extracting(StepResult::getName)
102+
.containsExactly(
103+
"assertThat '[a, b]'",
104+
"containsExactly '[a, b]'"
105+
);
106+
}
107+
90108
@AllureFeatures.Steps
91109
@Test
92110
void softAssertions() {

0 commit comments

Comments
 (0)