Skip to content

Commit 8edd42b

Browse files
committed
Improve logging.
1 parent 2a7544a commit 8edd42b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/Components/WebView/test/E2ETest/WebViewManagerE2ETests.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Diagnostics;
55
using Microsoft.AspNetCore.InternalTesting;
6+
using Xunit.Abstractions;
67

78
namespace Microsoft.AspNetCore.Components.WebViewE2E.Test;
89

@@ -40,17 +41,37 @@ public async Task CanLaunchPhotinoWebViewAndClickButton()
4041
FileName = "dotnet",
4142
Arguments = $"\"{photinoTestAppPath}\" --basic-test",
4243
RedirectStandardOutput = true,
44+
RedirectStandardError = true,
45+
UseShellExecute = false,
4346
},
4447
};
4548

4649
photinoProcess.Start();
4750

4851
var testProgramOutput = photinoProcess.StandardOutput.ReadToEnd();
52+
var testProgramError = photinoProcess.StandardError.ReadToEnd();
4953

5054
await photinoProcess.WaitForExitAsync().TimeoutAfter(TimeSpan.FromSeconds(30));
5155

52-
// The test app reports its own results by calling Console.WriteLine(), so here we only need to verify that
53-
// the test internally believes it passed (and we trust it!).
54-
Assert.Contains($"Test passed? {true}", testProgramOutput);
56+
// Use Assert.True with a custom message to include the full output in the failure message
57+
var expectedMessage = $"Test passed? {true}";
58+
var testPassed = testProgramOutput.Contains(expectedMessage);
59+
60+
if (!testPassed)
61+
{
62+
var errorInfo = $"Process exit code: {photinoProcess.ExitCode}\n" +
63+
$"Working directory: {photinoProcess.StartInfo.WorkingDirectory}\n" +
64+
$"Command: {photinoProcess.StartInfo.FileName} {photinoProcess.StartInfo.Arguments}\n" +
65+
$"PhotinoTestApp path: {photinoTestAppPath}\n\n" +
66+
$"=== Full Standard Output ===\n{testProgramOutput}\n" +
67+
$"=== End of Standard Output ===\n";
68+
69+
if (!string.IsNullOrEmpty(testProgramError))
70+
{
71+
errorInfo += $"\n=== Standard Error ===\n{testProgramError}\n=== End of Standard Error ===";
72+
}
73+
74+
Assert.True(testPassed, $"Expected to find '{expectedMessage}' in PhotinoTestApp output.\n\n{errorInfo}");
75+
}
5576
}
5677
}

0 commit comments

Comments
 (0)