Skip to content

Generate Allure Annotations for Test Files with AI

CI/CD for QAUpdated 2026-10-21basic
TL;DR

Reads a test file and annotates each test with Allure metadata (epic, feature, story, severity, link to spec, TMS link) based on file path conventions, commit message JIRA prefixes, and test naming: emits a diff, not a rewrite.

When to use it

  • Adding Allure reporting to an existing suite without rewriting tests.
  • Standardizing test metadata across a team where annotations are inconsistent.
  • Wiring JIRA / TestRail / Linear links to tests for traceability.
  • Onboarding engineers to Allure conventions.

The prompt

XML-tagged: works best with Claude
allure-annotations-generator.claude.mdprompt
<role>You are a test reporting specialist. You know that Allure annotations are most useful when they're consistent, and most accurate when they derive from file paths and naming, not from guesses.</role> <context>Allure annotations. For Playwright / Jest / Vitest use the runtime API from `allure-js-commons` (Allure 3 integrations: `import * as allure from 'allure-js-commons'`, every call awaited, e.g. `await allure.epic('Checkout')`); decorator syntax below is for Java / Python / TS-decorator frameworks:- `@epic("Checkout")`: top-level grouping- `@feature("Discount codes")`: feature within epic- `@story("Apply promo code at checkout")`: user story- `@severity("critical" | "blocker" | "normal" | "minor" | "trivial")`: bug-tracking severity if a test fails- `@link("https://...", "JIRA-1234")`: link to spec or related issue- `@tms("https://...", "TC-5678")`: link to test management system Conventions:- Epic derived from top-level test directory (`tests/checkout/...` → epic "Checkout")- Feature derived from second-level directory or filename- Story derived from `describe` block or test name- Severity inferred from test name (`smoke` → critical; `edge case` → minor)- Links from existing JIRA references in comments or commit messages</context> <task>For the test file below:1. Derive epic from file path (top-level dir).2. Derive feature from second-level dir or filename.3. Derive story from `describe` block name.4. Derive severity from test naming (use rules).5. Add JIRA / TMS links if present in comments or commit message.6. RESPECT existing annotations: never overwrite, only add missing.7. Emit as a DIFF showing only lines added.</task> <input>Test file path: {path}Test file content: {content}Recent commit message (for JIRA references): {commit_msg}Existing TMS pattern (if any): {tms_pattern}</input> <constraints>- Annotations are added at the test level (inside or above the `test(` / `it(` block), not at the file level.- DIFF format: show only ADDED lines, not modified ones.- Existing annotations preserved; never overwrite.- Severity rules:  - "smoke" / "critical path" in name → critical  - "edge case" / "rare" / "unlikely" in name → minor  - default → normal  - "blocker" / "showstopper" in name → blocker- Link format: `@link("<url>", "<label>")`.</constraints> <output_format>A unified diff (added lines only) showing the annotation insertions. Followed by a "Derivation log": bullets showing where each annotation came from.</output_format> <approach>Before writing, identify any existing annotations in the file: never overwrite.</approach>

Example

Input
Test file path: tests/checkout/discount-flow.spec.ts

Test file content:
```typescript
import { test, expect } from '@playwright/test';

test.describe('Discount code application', () => {
  test('happy path: apply SAVE20 on standard cart', async ({ page }) => {
    // Smoke test for discount feature
    await page.goto('/cart');
    await page.getByLabel('Discount code').fill('SAVE20');
    await page.getByRole('button', { name: 'Apply' }).click();
    await expect(page.getByTestId('discount-applied')).toBeVisible();
  });

  test('edge case: apply SAVE20 on cart over $1000', async ({ page }) => {
    // Related to JIRA-1242: discount silently fails on high-value carts
    // ... test body
  });
});
```

Recent commit message: "fix(checkout): correctly apply discount on high-value carts JIRA-1242"
Existing TMS pattern: TC-### linked at https://test-management.example.com/TC-
Output
## Derivation log

- **Epic = "Checkout"**: derived from top-level test directory (`tests/checkout/`)
- **Feature = "Discount flow"**: derived from filename (`discount-flow.spec.ts`)
- **Story = "Discount code application"**: derived from `describe` block name
- **Test 1 severity = critical**: comment "Smoke test for discount feature" + name "happy path"
- **Test 2 severity = minor**: name contains "edge case"; description matches "high-value carts" pattern
- **Test 2 link = JIRA-1242**: found in commit message + comment
- No existing annotations to preserve

## Unified diff (added lines only)

```diff
 import { test, expect } from '@playwright/test';
+import * as allure from 'allure-js-commons';

 test.describe('Discount code application', () => {
   test('happy path: apply SAVE20 on standard cart', async ({ page }) => {
+    await allure.epic('Checkout');
+    await allure.feature('Discount flow');
+    await allure.story('Discount code application');
+    await allure.severity('critical');
     // Smoke test for discount feature
     await page.goto('/cart');
     await page.getByLabel('Discount code').fill('SAVE20');
     await page.getByRole('button', { name: 'Apply' }).click();
     await expect(page.getByTestId('discount-applied')).toBeVisible();
   });

   test('edge case: apply SAVE20 on cart over $1000', async ({ page }) => {
+    await allure.epic('Checkout');
+    await allure.feature('Discount flow');
+    await allure.story('Discount code application');
+    await allure.severity('minor');
+    await allure.issue('https://jira.example.com/browse/JIRA-1242', 'JIRA-1242');
     // Related to JIRA-1242: discount silently fails on high-value carts
     // ... test body
   });
 });
```

If your team uses TMS links and has a TC-### for this discount flow, add manually:

```diff
+    await allure.tms('https://test-management.example.com/TC-XXXX', 'TC-XXXX');
```

Common pitfalls

  • Model overwrites existing annotations (e.g., changes severity that was manually set). Force 'preserve existing'.
  • Severity defaults to 'normal' without inference rules: re-prompt with explicit rule list.
  • JIRA links not added because comment/commit-message reference was missed: feed both to maximize coverage.
  • Annotations added at the file level (describe block) instead of per-test: Allure groups poorly when annotations aren't per-test.

Tips

  • Run this in batches per directory; epic/feature consistency improves when batching.
  • Pair with `github-actions-qa-pipeline` to wire Allure report upload as an artifact step.
  • Use `allure-playwright` instead of manual annotations if you can: auto-derives some metadata.
  • Re-run when adding new tests; consistency drifts otherwise.

FAQ

TestRail vs JIRA integration?

TestRail uses `@tms()` for test management; JIRA uses `@link()` for related issues. Use both: tms link to the test case in TestRail, link to bug or story in JIRA. Allure renders both in the report.

What severity scale should I use?

Allure ships with: blocker, critical, normal, minor, trivial. Map your team's severity to these. blocker = release-blocker; critical = customer-affecting; normal = default; minor = degraded UX; trivial = cosmetic.

What changed in Allure 3?

Allure 3 went 3.0.0 stable in December 2025 (first betas December 2024). It brings improved performance, native TestNG / JUnit 5 support, and a rewritten reporter UI. The annotation API is backward-compatible with Allure 2.

Can I generate annotations from test names alone?

Partially: severity yes (via keyword rules), epic/feature partially (via path), story yes (via describe block). Links must come from elsewhere (commit, TMS file). AI-generated annotations are 80% useful; the last 20% needs human input.