Skip to content

fix: emit file and line attributes on JUnit testcase#236

Merged
codito merged 1 commit into
spekt:masterfrom
chris-peterson:fix-null-filename
Jun 20, 2026
Merged

fix: emit file and line attributes on JUnit testcase#236
codito merged 1 commit into
spekt:masterfrom
chris-peterson:fix-null-filename

Conversation

@chris-peterson

@chris-peterson chris-peterson commented May 28, 2026

Copy link
Copy Markdown
Contributor

Context

The JUnit logger's <testcase> elements omit file and line. VSTest passes TestCase.CodeFilePath / LineNumber to the logger and TestResultInfo carries them, but the serializer doesn't emit them. The result is a blank Filename column in GitLab's Unit test reports UI — where "blank" renders as the literal string null.

This change adds a block in CreateTestCaseElement that reads those properties and emits them as attributes when present. The Jenkins JUnit XSD permits both, so the change is additive.

User-side requirement: populating the attributes requires <CollectSourceInformation>true</CollectSourceInformation> in the consumer's runsettings — the VSTest gate that tells xUnit/MSTest adapters to read PDBs. Without it, CodeFilePath arrives empty and the attributes are omitted (same as today).

Review guide

Core change

Schema

  • test/assets/JUnit.xsd:85 — add the two optional attributes so the acceptance-test XSD validator accepts the new output

Tests

Sibling formats unchanged: Xunit.Xml.TestLogger already emits <source-file>/<source-line> children on <test> (different format); NUnit.Xml.TestLogger's schema has no equivalent attributes.

Resolves #235

JUnit XML <testcase> elements omitted file and line, so GitLab's
Unit test reports UI rendered the Filename column as "null".
VSTest exposes the source path and line number via
TestCase.CodeFilePath / LineNumber and TestResultInfo already
carried them through; the JUnit serializer just wasn't reading
them.

The Jenkins JUnit XSD supports both attributes, so this is an
additive change. file is emitted when CodeFilePath is non-empty;
line is emitted when LineNumber > 0.

Resolves spekt#235
@codito codito merged commit 3dbb59f into spekt:master Jun 20, 2026
3 checks passed
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.

Filename is "null"

2 participants