Skip to content

Junit format system-out is missing for testcase but added only for testsuite #130

@jonesbusy

Description

@jonesbusy

Hi,

First of all thanks for this great project, it's super useful.

I'm running nunit and junit logger because I need both format to be imported on 3rd party tool.

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
    <LoggerRunSettings>
        <Loggers>
            <Logger friendlyName="nunit" enabled="True">
                <Configuration>
                    <LogFileName>nunit-results.xml</LogFileName>
                </Configuration>
            </Logger>
            <Logger friendlyName="junit" enabled="True">
                <Configuration>
                    <LogFileName>junit-results.xml</LogFileName>
                </Configuration>
            </Logger>
        </Loggers>
    </LoggerRunSettings>
</RunSettings>

When looking at the nunit-results.xml everything is correct.

The test only output

Console.WriteLine("[[ATTACHMENT|TodoApp.Test/bin/Debug/net8.0/title.png]]");
<test-run id="2" duration="2.1181359" testcasecount="1" total="1" passed="1" failed="0" inconclusive="0" skipped="0" result="Passed" start-time="2024-12-05T07:43:38Z" end-time="2024-12-05T07:43:41Z">
  <test-suite type="Assembly" name="TodoApp.Test.dll" fullname="********/ci-dotnet-core/TodoApp.Test/bin/Debug/net8.0/TodoApp.Test.dll" total="1" passed="1" failed="0" inconclusive="0" skipped="0" result="Passed" start-time="2024-12-05T07:43:38Z" end-time="2024-12-05T07:43:40Z" duration="2.1181359">
    <test-suite type="TestSuite" name="TodoApp" fullname="TodoApp" total="1" passed="1" failed="0" inconclusive="0" skipped="0" result="Passed" start-time="2024-12-05T07:43:38Z" end-time="2024-12-05T07:43:40Z" duration="2.1181359">
      <test-suite type="TestSuite" name="Test" fullname="TodoApp.Test" total="1" passed="1" failed="0" inconclusive="0" skipped="0" result="Passed" start-time="2024-12-05T07:43:38Z" end-time="2024-12-05T07:43:40Z" duration="2.1181359">
        <test-suite type="TestFixture" name="ApiTests" fullname="TodoApp.Test.ApiTests" classname="TodoApp.Test.ApiTests" total="1" passed="1" failed="0" inconclusive="0" skipped="0" result="Passed" start-time="2024-12-05T07:43:38Z" end-time="2024-12-05T07:43:40Z" duration="2.1181359">
          <test-case name="HasTitle" fullname="TodoApp.Test.ApiTests.HasTitle" methodname="HasTitle" classname="ApiTests" result="Passed" start-time="2024-12-05T07:43:38Z" end-time="2024-12-05T07:43:40Z" duration="2.1181359" asserts="0" seed="646563755">
            <output><![CDATA[[[ATTACHMENT|TodoApp.Test/bin/Debug/net8.0/title.png]]

]]></output>
          </test-case>
        </test-suite>
      </test-suite>
    </test-suite>
    <errors />
  </test-suite>
</test-run>

But when looking at junit-results.xml the system-out is not linked to the test case but the test suite. And it contains irelevant information. Additionnally the CDATA is missing

<testsuites>
  <testsuite name="TodoApp.Test.dll" tests="1" skipped="0" failures="0" errors="0" time="2.1181359" timestamp="2024-12-05T07:43:38" hostname="NB27764" id="0" package="TodoApp.Test.dll">
    <properties />
    <testcase classname="TodoApp.Test.ApiTests" name="HasTitle" time="2.1181359" />
    <system-out>[[ATTACHMENT|TodoApp.Test/bin/Debug/net8.0/title.png]]


Test Framework Informational Messages:
NUnit Adapter 4.6.0.0: Test execution started
Running selected tests in ******/ci-dotnet-core/TodoApp.Test/bin/Debug/net8.0/TodoApp.Test.dll
   NUnit3TestExecutor discovered 1 of 1 NUnit test cases using Current Discovery mode, Non-Explicit run
[[ATTACHMENT|TodoApp.Test/bin/Debug/net8.0/title.png]]

NUnit Adapter 4.6.0.0: Test execution complete
</system-out>
    <system-err></system-err>
  </testsuite>
</testsuites>

I would expect to see something like

<testcase classname="TodoApp.Test.ApiTests" name="HasTitle" time="2.3149900" >
    <system-out>[[ATTACHMENT|TodoApp.Test/bin/Debug/net8.0/title.png]]</system-out>
</testcase>

I have compared with other junit format and the system-out is well supported for testcase block

For example

<testcase name="has title" classname="ui.spec.ts" time="1.881">
<system-out>
<![CDATA[[[ATTACHMENT|screenshots/title.png]]

[[ATTACHMENT|test-results/ui-has-title-firefox/video.webm]]
]]>
</system-out>
</testcase>
  • Test Framework (choose one): Nunit
  • .NET project version, sdk version (choose applicable): net8.0
  • Command line used (please share the test run command): dotnet test --settings:ui.runsettings.
  • OS: Linux/Windows/Mac

Expected behavior
A clear and concise description of what you expected to happen.

Other details

  • Here's a minimal repro project I don't have public, but I can publish one if needed
  • I have attached logs from dotnet test --diag:log.txt On don't think there is anything useful there, but I can provide if needed

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions