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
65 changes: 63 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,83 @@ on:
- 'main'
- 'hotfix-*'

concurrency:
# On main, we don't want any jobs cancelled.
# On PR branches, we cancel the job if new commits are pushed.
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
env:
ALLURE_MATRIX_ENV: ubuntu-jdk-21
ALLURE_TEST_DUMP_NAME: allure-results-test-jdk-21
steps:
- uses: actions/checkout@v6

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

- 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.mjs --rerun 2 --environment="${{ env.ALLURE_MATRIX_ENV }}" --dump="${{ env.ALLURE_TEST_DUMP_NAME }}" -- ./gradlew --no-build-cache cleanTest test

- name: "Upload Allure test dump"
if: always()
uses: actions/upload-artifact@v7
with:
name: ${{ env.ALLURE_TEST_DUMP_NAME }}
path: ./${{ env.ALLURE_TEST_DUMP_NAME }}.zip

report:
needs: [build]
name: "Build report"
runs-on: ubuntu-latest
if: always()
permissions:
contents: read
pull-requests: write
checks: write
env:
ALLURE_SERVICE_TOKEN: ${{ secrets.ALLURE_SERVICE_TOKEN }}
steps:
- uses: actions/checkout@v6

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

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

- name: "Generate Allure report"
run: npx -y allure@3 generate --config ./allurerc.mjs --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.
1 change: 1 addition & 0 deletions allure-assertj/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-assertj
1 change: 1 addition & 0 deletions allure-attachments/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-attachments
3 changes: 3 additions & 0 deletions allure-awaitility/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-awaitility
1 change: 1 addition & 0 deletions allure-citrus/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-citrus
1 change: 1 addition & 0 deletions allure-cucumber4-jvm/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
allure.model.indentOutput=true
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-cucumber4-jvm
1 change: 1 addition & 0 deletions allure-cucumber5-jvm/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
allure.model.indentOutput=true
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-cucumber5-jvm
1 change: 1 addition & 0 deletions allure-cucumber6-jvm/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
allure.model.indentOutput=true
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-cucumber6-jvm
1 change: 1 addition & 0 deletions allure-cucumber7-jvm/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
allure.model.indentOutput=true
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-cucumber7-jvm
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-descriptions-javadoc
1 change: 1 addition & 0 deletions allure-grpc/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-grpc
3 changes: 3 additions & 0 deletions allure-hamcrest/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-hamcrest
1 change: 1 addition & 0 deletions allure-httpclient/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-httpclient
1 change: 1 addition & 0 deletions allure-httpclient5/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-httpclient5
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]+"));
}
}
3 changes: 3 additions & 0 deletions allure-java-commons-test/src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allure.results.directory=build/allure-results
allure.label.epic=#project.description#
allure.label.module=allure-java-commons-test
Loading
Loading