Skip to content

Support custom source and request attributes in JUnit XML report - #89

Draft
Burgyn with Copilot wants to merge 2 commits into
masterfrom
copilot/support-custom-attributes-junit-xml
Draft

Support custom source and request attributes in JUnit XML report#89
Burgyn with Copilot wants to merge 2 commits into
masterfrom
copilot/support-custom-attributes-junit-xml

Conversation

Copilot AI commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

JUnit XML reports lack metadata to distinguish inline tests (from .http files) from .csx script tests, blocking external tooling (IDE extensions) from correlating test results with HTTP requests.

Changes

  • TestResult — Add nullable SourceType and RequestName properties to the base record
  • TestFactory — Set SourceType = "inline" and RequestName from RequestExecutionContext.Name for inline tests
  • Registrator — Set SourceType = "csx" for script-registered tests
  • Tester — Propagate both fields when converting NotRunPassed/Failed
  • JUnitXmlWriter.WriteTestCase — Accept optional sourceType/requestName, emit as XML attributes when non-null
  • JUnitXmlTestResultsSummaryReporter — Thread SourceType/RequestName from each TestResult variant to the writer

Example output

<testcase name="[1] Status code should match" time="0.003" classname="002-Edit-Car" source="inline" request="EditCarRequest" />
<testcase name="Engine type should match" time="0.006" classname="002-Edit-Car" source="csx" />

Attributes are omitted entirely when not set, so existing consumers are unaffected.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/TeaPie/TeaPie/tests/TeaPie.Tests/bin/Debug/net8.0/TeaPie.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/TeaPie/TeaPie/tests/TeaPie.Tests/bin/Debug/net8.0/TeaPie.Tests.deps.json /home/REDACTED/work/TeaPie/TeaPie/tests/TeaPie.Tests/bin/Debug/net8.0/testhost.dll --port 39849 --endpoint 127.0.0.1:039849 --role client --parentprocessid 4830 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>🚀 [NEW] Support Custom Attributes in JUnit XML Report for Test Source and Request Name</issue_title>
<issue_description>## 🫴 Proposal
Introduce support for custom attributes in JUnit XML reports generated by TeaPie. This feature would allow TeaPie to output additional metadata for each <testcase> element in the JUnit XML—such as the source of the test (inline vs. .csx) and, for inline tests, a reference to the related HTTP request name. These attributes will enable better integration with external tools (such as IDE extensions) that visualize test results in the context of the HTTP requests they belong to.

Example attributes:

  • source="inline" or source="csx"
  • request="EditCarRequest" (for inline tests)

Example output:

<testcase name="[1] Status code should match one of these: [200, 201]" time="0.003" classname="002-Edit-Car" source="inline" request="EditCarRequest" />
<testcase name="Engine type and people capacity should match after edit." time="0.006" classname="002-Edit-Car" source="csx" />

✨ Motivation

When integrating TeaPie with external tools (such as custom IDE extensions for HTTP workflows), it's necessary and useful to distinguish between inline tests (defined in .http files and attached to specific requests) and tests defined in .csx scripts. Currently, the JUnit XML output does not provide this information, making it unreliable to group or filter test results in these visual tools. Adding such attributes should be safe and non-breaking, as unknown XML attributes should be ignored by JUnit XML consumers (including CI/CD tools like GitHub Actions).

💡 Possible implementation

Based on the current TeaPie codebase:

  • Extend the TestResult model to include optional metadata fields such as SourceType (string: "inline" or "csx") and RequestName (string, nullable).
  • Pass these fields through the reporting pipeline: When calling RegisterTestResult in TestResultsSummaryReporter, ensure these fields are set for each test.
  • Update the XML output logic in src/TeaPie/Reporting/JUnitXmlTestResultsSummaryReporter.cs and especially the JUnitXmlWriter:
    • Update the writer so that WriteTestCase can accept and emit these custom attributes when writing the <testcase> XML node.
    • For .csx tests, default to source="csx" and omit the request attribute.
    • For inline tests (from HTTP files), include both source="inline" and the request attribute.

Example change to the writer's API:

writer.WriteTestCase(
    className,
    testName,
    duration,
    isSkipped,
    errorMessage,
    stackTrace,
    sourceType: "inline" or "csx",
    requestName: "EditCarRequest" // only for inline tests
);

And in the XML generation:

writer.WriteAttribute("source", sourceType);
if (!string.IsNullOrEmpty(requestName)) {
    writer.WriteAttribute("request", requestName);
}

➕ Additional context

This feature enables richer integrations for developer tools (such as VS Code extensions) that visualize requests and their associated tests, improving the user experience for TeaPie users working with complex API suites.

References:

<agent_instructions>Implement this feature</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

- Add SourceType and RequestName properties to TestResult model
- Set SourceType='inline' and RequestName for inline tests in TestFactory
- Set SourceType='csx' for CSX tests in Registrator
- Propagate SourceType and RequestName in Tester when creating Passed/Failed results
- Add sourceType and requestName parameters to JUnitXmlWriter.WriteTestCase
- Pass SourceType and RequestName from TestResult to writer in JUnitXmlTestResultsSummaryReporter
- Add tests for new attributes in JUnitXmlWriterShould and JUnitXmlTestResultsSummaryReporterShould

Co-authored-by: Burgyn <5930822+Burgyn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Kros-sk/TeaPie/sessions/9641a5f3-e740-4ba9-ad44-ceb0f42b5fa4
Copilot AI changed the title [WIP] Add support for custom attributes in JUnit XML report Support custom source and request attributes in JUnit XML report Mar 22, 2026
Copilot AI requested a review from Burgyn March 22, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 [NEW] Support Custom Attributes in JUnit XML Report for Test Source and Request Name

2 participants