Skip to content

TestRunDirectory contains an ugly path in linux containers. #6757

@DevAlsicJanDeclercq

Description

@DevAlsicJanDeclercq

Describe the bug

When running unit test in an linux container, I have issues with the path in TestRunDirectory. it contains a .\ in the path. This makes some (not all) unit tests fail.

Steps To Reproduce

Run a unit test in a container. Check the TestRunDirectory variable.

Expected behavior

TestRunDirectory should be a valid unix path.

Actual behavior

I get a path like this /__w/90/Contoso.MyUnitTest/build/.\TestResults/Deploy_ 20251016T082547_935/

The .\ makes that some tests fail..

Additional context

My workaround:

[TestClass]
public class MyTest {

    private static string? _testRunDirectory;

    public TestContext TestContext { get; set; }

    [ClassInitialize]
    public static void InitTest(TestContext testCtx)
        => _testRunDirectory = testCtx.TestRunDirectory.Replace(".\\", "")
 
    ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: MSTestIssues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions