Skip to main content

Spec-to-Test Generation

Upload a product requirements document (PRD), specification, or design brief and let Agnox automatically generate a structured library of draft test cases — ready to review, edit, and import into your suite.


Overview​

Spec-to-Test (Feature F) reads a PDF, DOCX, or Markdown file and runs a 4-stage agentic pipeline that converts raw requirements into ITestCase-compatible records. The entire pipeline streams progress in real time via Server-Sent Events (SSE), so you see each stage complete before the next begins.


Prerequisites​

  • The specToTest feature flag must be enabled in Settings → Features → AI Features.
  • You must have a Developer or Admin role (Viewers cannot create test cases).
  • An active project must be selected in the global Project Selector.

Supported File Formats​

FormatExtensionParser
PDF.pdfpdf-parse (text extraction)
Word Document.docxmammoth (raw text extraction)
Markdown / plain text.md, .txtNative string

Maximum file size: 10 MB


How to Use​

  1. Navigate to Test Cases from the sidebar.
  2. Click Import from Spec (emerald button in the page header).
  3. The Spec-to-Test Wizard opens — 3 steps:

Step 1 — Upload & Style​

  • Drag and drop your file or click to browse.
  • Choose a Test Style:
StyleDescription
BDD (Gherkin)Steps written as Given / When / Then
ProceduralNumbered action → expected result steps
TDDFocused on unit-level assertions
  • Click Generate Tests to start the pipeline.

Step 2 — Live Pipeline Progress​

The 4-stage pipeline runs and streams progress to your browser:

StageLabelWhat Happens
1Reading document…File text extracted; requirements structured into IRequirementBlock[] by the Extractor LLM
2Generating test drafts…Generator LLM drafts IDraftTestCase[] per requirement in the selected style
3Reviewing for accuracy…Critic LLM deduplicates against existing tests in the project and removes hallucinated or vague steps
4Formatting test cases…Approved drafts are transformed into the canonical ITestCase shape

Each stage shows a progress indicator that turns into a check mark on completion.

Step 3 — Review & Import​

  • A stats bar shows: Generated, Filtered Out, and Ready to Import counts.
  • Tests are grouped by suite (accordion). Expand any suite to preview individual steps.
  • A collapsed Filtered Out section lists dropped tests with the Critic's drop reason.
  • Click Import N Tests to batch-insert all approved cases into your project's Test Cases.

Import is performed in chunks of 50 tests via POST /api/test-cases/bulk. Large spec documents are handled automatically.


API Reference​

MethodPathAuthFeature FlagDescription
POST/api/ai/spec-to-testsJWTspecToTestMultipart upload. Fields: file (binary), projectId (string), testStyle (bdd | procedural | tdd). Returns an SSE stream.

SSE Event Shape​

event: progress
data: { "stage": 1, "label": "Extracting requirements…", "count": 12 }

event: progress
data: { "stage": 3, "label": "Reviewing for accuracy…", "count": 8 }

event: complete
data: { "generated": [...ITestCase], "dropped": [...{ title, reason }] }

event: error
data: { "message": "Stage 2 (Generator) returned invalid JSON. Please retry." }

Long-running pipelines stream progress continuously, so they are not cut off by proxy timeouts.


Deduplication Logic​

Stage 3 (Critic) performs a two-layer deduplication before the LLM review:

  1. Suite-scoped pre-filter: Fetches existing test case titles for the target suites in the project.
  2. Full-text search: For new suites, searches existing test case titles across the project.

The LLM Critic then receives both the draft cases and the pre-filtered existing titles, and is instructed to drop any draft that is a duplicate, hallucinated, or untestable.


Troubleshooting​

IssueLikely Cause
"Import from Spec" button not visiblespecToTest feature flag is off, or you have Viewer role
Stage 1 returns 0 requirementsDocument text could not be parsed — ensure the file is not scanned/image-only
"Search failed" warning during Stage 3Deduplication search is temporarily unavailable — results may include duplicates; retry later or contact support if it persists
All tests dropped by CriticMost drafts were duplicates of existing test cases in the project