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
56 changes: 54 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,70 @@ jobs:
build:
name: "Build"
runs-on: ubuntu-latest
env:
ALLURE_DUMP_NAME: allure-results-build
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: '20'

- name: "Set up JDK"
uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version: 21

- name: "Setup Gradle"
uses: gradle/actions/setup-gradle@v6
with:
gradle-version: 'wrapper'

- name: "Build with Gradle"
run: ./gradlew build -x test --scan

- name: "Run tests"
- name: "Run tests with Allure"
if: always()
run: ./gradlew --no-build-cache cleanTest test
run: npx -y allure@3 run --config ./allurerc.yml --dump="${{ env.ALLURE_DUMP_NAME }}" -- ./gradlew --no-build-cache cleanTest test

- name: "Upload Allure dump"
if: always()
uses: actions/upload-artifact@v5
with:
name: ${{ env.ALLURE_DUMP_NAME }}
path: ./${{ env.ALLURE_DUMP_NAME }}.zip
if-no-files-found: error

report:
needs: build
name: "Build Allure Report"
runs-on: ubuntu-latest
if: always()
permissions:
contents: read
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: '20'

- name: "Download Allure dumps"
uses: actions/download-artifact@v6
with:
pattern: allure-results-*
path: ./
merge-multiple: true

- name: "Generate Allure report"
run: npx -y allure@3 generate --config ./allurerc.yml --dump="allure-results-*.zip" --output=./build/allure-report

- name: "Post Allure summary"
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
uses: allure-framework/allure-action@v0
with:
report-directory: ./build/allure-report
github-token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Project Guide

Use [Allure Agent Mode](docs/allure-agent-mode.md) for all test-related work in this repository.

- Read `docs/allure-agent-mode.md` before designing, writing, reviewing, validating, debugging, or enriching tests.
- Run test-executing commands through `allure run`, including smoke checks after small edits.
- Use `./gradlew` for repo-local test commands and scope runs to the smallest relevant module or task.
- If agent-mode output is missing or incomplete, debug that first rather than relying on console-only conclusions.
7 changes: 7 additions & 0 deletions allure-java-commons-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ dependencies {
api("org.apache.commons:commons-lang3")
api(project(":allure-java-commons"))
implementation("com.fasterxml.jackson.core:jackson-databind")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation(project(":allure-junit-platform"))
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

tasks.jar {
Expand All @@ -15,3 +18,7 @@ tasks.jar {
))
}
}

tasks.test {
useJUnitPlatform()
}
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.test;

import io.qameta.allure.model.Label;
import io.qameta.allure.model.Status;
import io.qameta.allure.model.TestResult;
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class AllurePredicatesTest {

@Test
void shouldMatchStatusAndLabels() {
final TestResult result = new TestResult()
.setStatus(Status.PASSED)
.setLabels(List.of(new Label().setName("feature").setValue("attachments")));

assertTrue(AllurePredicates.hasStatus(Status.PASSED).test(result));
assertTrue(AllurePredicates.hasLabel("feature", "attachments").test(result));
assertFalse(AllurePredicates.hasStatus(Status.FAILED).test(result));
assertFalse(AllurePredicates.hasLabel("feature", "steps").test(result));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.test;

import io.qameta.allure.Allure;
import io.qameta.allure.model.TestResult;
import io.qameta.allure.model.TestResultContainer;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;

class AllureResultsWriterStubTest {

@Test
void shouldStoreResultsContainersAndAttachments() {
final AllureResultsWriterStub writer = new AllureResultsWriterStub();
final TestResult testResult = new TestResult()
.setUuid("test-uuid")
.setName("demo");
final TestResultContainer container = new TestResultContainer()
.setUuid("container-uuid")
.setChildren(List.of("test-uuid"));

Allure.step("Store a test result, its container, and an attachment", () -> {
writer.write(testResult);
writer.write(container);
writer.write("payload.txt", new ByteArrayInputStream("payload".getBytes(StandardCharsets.UTF_8)));
});

Allure.step("Verify the stub exposes the written runtime artifacts", () -> {
assertSame(testResult, writer.getTestResultByName("demo"));
assertEquals(List.of(container), writer.getTestResultContainersForTestResult(testResult));
assertArrayEquals("payload".getBytes(StandardCharsets.UTF_8), writer.getAttachments().get("payload.txt"));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.test;

import io.qameta.allure.Allure;
import io.qameta.allure.model.Status;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class RunUtilsTest {

@Test
void shouldCaptureFailureStatusWithinSyntheticTestContext() {
final AllureResults results = Allure.step("Execute a synthetic test context that raises an assertion error", () ->
RunUtils.runWithinTestContext(() -> {
throw new AssertionError("boom");
})
);

Allure.step("Verify the captured synthetic test result is marked as failed", () -> {
assertEquals(1, results.getTestResults().size());
assertEquals(Status.FAILED, results.getTestResults().get(0).getStatus());
assertTrue(results.getTestResults().get(0).getStatusDetails().getMessage().contains("boom"));
});
}

@Test
void shouldAttachNestedRunArtifactsToOuterLifecycle() {
final AllureResults results = Allure.step("Execute a nested synthetic run and capture its emitted attachments", () ->
RunUtils.runWithinTestContext(() ->
RunUtils.runWithinTestContext(() -> {
})
)
);

Allure.addAttachment("nested-attachment-keys", String.join("\n", results.getAttachments().keySet()));
Allure.step("Verify the outer lifecycle receives serialized artifacts from the nested run", () -> {
assertFalse(results.getAttachments().isEmpty());
assertTrue(results.getAttachments().values().stream()
.map(bytes -> new String(bytes, java.nio.charset.StandardCharsets.UTF_8))
.anyMatch(body -> body.contains("\"uuid\"")));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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.test;

import io.qameta.allure.Allure;
import io.github.benas.randombeans.api.EnhancedRandom;
import org.junit.jupiter.api.Test;

import java.util.concurrent.atomic.AtomicReference;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

class TestUtilitiesTest {

@Test
void shouldGenerateStableThreadLocalRandomPerThread() throws Exception {
final EnhancedRandom mainThread = ThreadLocalEnhancedRandom.current();
final AtomicReference<EnhancedRandom> workerThread = new AtomicReference<>();
final Thread thread = new Thread(() ->
workerThread.set(ThreadLocalEnhancedRandom.current())
);

Allure.step("Resolve thread-local random generators on two threads and compare their identities", () -> {
thread.start();
thread.join();
Allure.addAttachment(
"thread-local-random-identities",
"main=" + System.identityHashCode(mainThread)
+ "\nworker=" + System.identityHashCode(workerThread.get())
);
assertSame(mainThread, ThreadLocalEnhancedRandom.current());
assertNotSame(mainThread, workerThread.get());
});
}

@Test
void shouldGenerateExpectedRandomTestDataShapes() {
final String name = TestData.randomName();
final String id = TestData.randomId();
final String value = TestData.randomString(16);

assertEquals(10, name.length());
assertEquals(10, id.length());
assertEquals(16, value.length());
assertTrue(name.matches("[A-Za-z]+"));
assertTrue(id.matches("[A-Za-z0-9]+"));
assertTrue(value.matches("[A-Za-z0-9]+"));
}
}
10 changes: 10 additions & 0 deletions allure-junit-platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ tasks.jar {
}

tasks.test {
// The Allure Gradle adapter adds this module's published artifact to the
// test runtime classpath, so make the jar/task relationship explicit when
// jar and test are scheduled in the same build.
dependsOn(tasks.jar)
systemProperty("junit.jupiter.execution.parallel.enabled", "false")
useJUnitPlatform()
exclude("**/features/*")
}

tasks.named<Pmd>("pmdMain") {
// PMD type resolution reads the main compile classpath, which also
// contains this module's published artifact via the Allure adapter setup.
dependsOn(tasks.jar)
}

val spiOffJar: Jar by tasks.creating(Jar::class) {
from(sourceSets.getByName("main").output)
archiveClassifier.set("spi-off")
Expand Down
11 changes: 11 additions & 0 deletions allure-junit4-aspect/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ dependencies {
api(project(":allure-junit4"))
compileOnly("junit:junit:$junitVersion")
compileOnly("org.aspectj:aspectjrt")
testImplementation("junit:junit:$junitVersion")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.aspectj:aspectjrt")
testImplementation("org.mockito:mockito-core")
testImplementation("org.slf4j:slf4j-simple")
testImplementation(project(":allure-junit-platform"))
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

tasks.jar {
Expand All @@ -15,3 +22,7 @@ tasks.jar {
))
}
}

tasks.test {
useJUnitPlatform()
}
Loading
Loading