Skip to content

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

Description

@piripi-heidi

🤔 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:
<testcase classname="Login Feature" file="features/login.feature" name="User can login" time="5.2">
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions