cucumber / cucumber/junit-xml-formatter

Add file attribute to <testcase> elements for CI/CD tool compatibility

Open
#130 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3
Forks
8
Avg merge
3d 18h
Merged PRs (30d)
4

Description

### 🤔 What's the problem you're trying to solve?

Many CI/CD analytics tools (e.g., Trunk Analytics, Codecov) require a file attribute on elements to map test results back to source files. This enables features like:
Code owner matching for test failures
File-level test coverage visualization
Linking test results to specific feature files
Currently, the JUnit XML output only includes classname, name, and time on testcase elements:

Tools like Trunk Analytics report warnings like:
> report has test cases with missing file or filepath

### ✨ What's your proposed solution?

add the file attribute using the already-available pickle.uri:
`
`
This is a minimal change (~3 lines of code):
makeReport.ts:

` interface ReportTestCase {
classname: string
name: string
time: number
+ file: string
failure?: ReportFailure
output: string
}`

` return {
classname: testClassName ?? lineage.feature?.name ?? pickle.uri,
name: testNamingStrategy.reduce(lineage, pickle),
time: durationToSeconds(query.findTestCaseDurationBy(testCaseStarted)),
+ file: pickle.uri,
failure: makeFailure(query, testCaseStarted),`

index.ts:

` const testcaseElement = builder.ele('testcase', {
classname: testCase.classname,
name: testCase.name,
time: testCase.time,
+ file: testCase.file,
})`

### ⛏ Have you considered any alternatives or workarounds?

Alternatives Considered
Post-processing the XML to add file paths from the JSON report (current workaround)
Using classname to store the file path (loses the feature name information)

### 📚 Any additional context?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reading makeReport.ts to trace the ReportTestCase data from pickle.uri, then inspect index.ts where testcase elements are built. Add the file value to the report data and XML output, and verify that generated testcase elements include the feature URI while retaining the existing attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.