Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
jonesbusy opened this issue Dec 5, 2024 · 4 comments
Open
2 tasks

Comments

@jonesbusy
Copy link

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

@jonesbusy
Copy link
Author

Just reallized there was a PR on the old repo : https://github.com/spekt/junit.testlogger/pull/47/files

Perhaps it could be revived here

@codito
Copy link
Contributor

codito commented Dec 6, 2024

@jonesbusy thanks for reporting this issue. We definitely want to support reporting attachments for junit.

Would you be interested to contribute/port the above PR to this repo?

@jonesbusy
Copy link
Author

I can try but for the moment I'm struggling to run acceptance tests on my environment (.NET 8.0 / WSL2)

I'm not familiar with .NET environment

I don't know what was decided at the end, but my idea would be simple for the moment

Update the xsd schema by allowing system-out and system-err at the testcase level in order to support the [[ATTACHMENT syntax used by gitlab and jenkins (https://plugins.jenkins.io/junit-attachments/)

@codito
Copy link
Contributor

codito commented Dec 6, 2024

I haven't tried building this repo in WSL2. What's the error?

Update the xsd schema by allowing system-out and system-err at the testcase level in order to support the [[ATTACHMENT syntax used by gitlab and jenkins (https://plugins.jenkins.io/junit-attachments/)

The approach looks good to me.

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

No branches or pull requests

2 participants