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

StandardOutput/StandardError of launched process is not shown #4828

Closed
mxschmitt opened this issue Jan 25, 2023 · 2 comments · Fixed by #4998
Closed

StandardOutput/StandardError of launched process is not shown #4828

mxschmitt opened this issue Jan 25, 2023 · 2 comments · Fixed by #4998
Labels

Comments

@mxschmitt
Copy link
Member

Describe the bug

When launching a process StandardOutput and StandardError is not shown. When launching the same code via a new console app it works.

Steps To Reproduce

Provide the steps to reproduce the behavior:

  1. Create a new MSTest project via: dotnet new mstest -n PlaywrightTests; cd PlaywrightTests
  2. Modify the UnitTest1.cs file and put the following into it:
using System.Diagnostics;

namespace PlaywrightTests;

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {
        var process = new Process();
        process.StartInfo.FileName = "C:\\Program Files\\PowerShell\\7\\pwsh.exe";
        process.StartInfo.Arguments = "-c \"echo 'hello from stdout'; Write-Error 'hello from stderr'\"";
        process.Start();
        process.WaitForExit();
    }
}
  1. Run the test via dotnet test

Expected behavior

Output shown

Actual behavior

Nothing shown

Additional context

Affected project: https://github.com/microsoft/playwright-dotnet

When doing the same via dotnet new console it works and gets displayed.

@engyebrahim
Copy link
Member

Hi @mxschmitt thanks for reporting that.
I managed to reproduce and marked it as bug. we will work on it soon.

@MarcoRossignoli
Copy link
Contributor

I did some tests with our new test runner https://learn.microsoft.com/dotnet/core/testing/unit-testing-mstest-runner-intro where we're sure we're not capturing the console output and looks like MSTest is not the culprit here but the VSTest platform that's capturing the output.
image

[TestClass]
public class TestClass
{
    [TestMethod]
    public void Test1()
    {
        var process = new Process();
        process.StartInfo.FileName = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
        process.StartInfo.Arguments = "-c \"echo 'hello from stdout'; Write-Error 'hello from stderr'\"";
        process.Start();
        process.WaitForExit();
    }
}

@Evangelink Evangelink transferred this issue from microsoft/testfx Jan 15, 2024
@MarcoRossignoli MarcoRossignoli removed their assignment Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants