Skip to content

Add precondition and expected result support - #1466

Open
andrcuns wants to merge 1 commit into
mainfrom
runtime-api-expected-preconditions
Open

andrcuns wants to merge 1 commit into
mainfrom
runtime-api-expected-preconditions

Conversation

@andrcuns

@andrcuns andrcuns commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Context

Java tests can now report preconditions and expected results separately from the test description. This makes it easier to explain what must be true before a test runs and what a successful outcome should look like, without combining everything into one description.

Use the new runtime helpers to provide Markdown content:

Allure.precondition("User is **logged in**");
Allure.expectedResult("**Dashboard** is displayed");

Use explicit HTML when rich formatting is needed:

Allure.preconditionHtml("<p>User is logged in</p>");
Allure.expectedResultHtml("<p>Dashboard is displayed</p>");

These helpers work like Java's description helpers:

  • Calls inside a test update that test.
  • Calls inside a before fixture provide defaults for tests linked to that fixture's scope.
  • Explicit test values, including empty strings, take precedence over scope defaults independently for each field.
  • Markdown and HTML values are stored separately; HTML takes precedence when rendered in a supporting report.

The fields are written to test results as precondition, preconditionHtml, expectedResult, and expectedResultHtml. Custom integrations can also set them through the model's fluent accessors. Existing tests need no changes.

This brings Java support in line with the Ruby integration, while following Java's shared-setup metadata conventions. In Allure 3 Awesome reports, the corresponding report support displays Precondition before test execution and Expected result after teardown.

Checklist

@andrcuns andrcuns added the pr:new feature Change that add something new for end users label Nov 2, 2026
@andrcuns andrcuns self-assigned this Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Allure Report Summary

     Environment Duration Stats New Flaky Retry
     All tests 23m 56s Passed tests⁠ 1817
Failed tests⁠ 2
Skipped tests⁠ 1
104 0 0
     ubuntu-jdk-17 8m 48s Passed tests⁠ 885
Failed tests⁠ 1
Skipped tests⁠ 1
52 0 0
     ubuntu-jdk-25 15m 8s Passed tests⁠ 932
Failed tests⁠ 1
52 0 0

Reports: Awesome

Context: 9086f5ea, Build

Allure TestOps: Allure Java GitHub actions run (2026-11-03T16:18:15.080Z)

Artifacts used (2)
  • allure-results-test-jdk-17.zip
  • allure-results-test-jdk-25.zip

@andrcuns
andrcuns force-pushed the runtime-api-expected-preconditions branch from 4cead55 to 362df73 Compare November 2, 2026 16:10
@andrcuns
andrcuns requested review from a team and epszaw and removed request for a team November 3, 2026 05:40
@andrcuns
andrcuns marked this pull request as ready for review November 3, 2026 05:40
@baev
baev force-pushed the runtime-api-expected-preconditions branch from bf56bc6 to 9086f5e Compare November 3, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:new feature Change that add something new for end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant