Skip to content

Logging from WebApplicationFactory can no longer be captured in 2.2.9 #1083

Open

Description

Description

We are developing a ASP.NET Core application and for testing we use the ASP.NET Core TestHost (WebApplicationFactory) to facilitate integration testing.
To capture the logging we replace the ILoggerFactory with an implementation that uses the TestContext to write the application logging so it can be used for debugging if tests fail.

Since version 2.2.9 logging is no longer reliably captured.

Steps to reproduce

  1. Download this example solution: TestOutputTest.zip
  2. Run the test
  3. Check the TestContext messages, all the logging output for the request is missing.
    As a test I added a "Hello from Get" message to the controller, which is also not visible.

Expected behavior

All the messages passed to the TestContext for a single test are captured.
If MSTest.TestAdapter and MSTest.TestFramework version 2.2.8 are used the output is captured as expected

Actual behavior

Messages are missing, probably because they are in a different async context.

Environment

.NET SDK 6.0.202
Windows 11
Visual Studio 2022 (17.1.4)
MsTest 2.2.9

Also tried using the pre-release version 2.2.10-preview-20220414-01, but same issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions