Skip to content

[Bug]: test-results with junit-logger are deleted #3251

@asgr-sydbank

Description

@asgr-sydbank

Version

1.49.0, Microsoft.Playwright.MSTest

Steps to reproduce

  1. create project: dotnet new mstest-playwright -n test-pw-junit
  2. add screenshot-code to test-example: await Page.ScreenshotAsync(new(){Path = "stuff.jpeg"});TestContext.AddResultFile("stuff.jpeg");
  3. add logger-package dotnet add package JunitXml.TestLogger -v 7.0.2
  4. run tests: dotnet test --logger:junit --results-directory ./test-results

Expected behavior

Notice below how the trx-logger does it. it has attachments added the test-results, and the references in the trx-file has relative references to those attachments. That means I can easily move the test-results folder, and use it for test-results in Azure-pipelines:

Image

Actual behavior

The test-results directory is empty, except for the report-file.

Image

There's results in there for a while during the test-run, but they dissappear before the test-run is over:

Image

I tried out TestContext.ResultsDirectory for attachments. Notice that attachments are gone from the test-results-directory. This seems to be an issue with the logger and playwright - the junit-report is referencing paths that don't exist.

Image

Just like the default trx-logger, the junit-logger for playwright with Node.js also does this well:

  1. It produces test-attachments in the test-results-directory.
  2. The report has relative paths to the attachments.
Image

Additional context

Here's my original issue on the dotnet junit-logger: spekt/testlogger#201

They've agreed that I can implement configuration to generate relative-paths in the test-report. What I need in this issue, is to not have the system delete the test-results if I write attachments to the directory.

Environment

- Operating System: win11
- CPU: x86 64 something
- Browser: N/A
- .NET Version (TFM): net9.0
- Other info:

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