|
3 | 3 |
|
4 | 4 | using System.Diagnostics; |
5 | 5 | using Microsoft.AspNetCore.InternalTesting; |
| 6 | +using Xunit.Abstractions; |
6 | 7 |
|
7 | 8 | namespace Microsoft.AspNetCore.Components.WebViewE2E.Test; |
8 | 9 |
|
@@ -40,17 +41,37 @@ public async Task CanLaunchPhotinoWebViewAndClickButton() |
40 | 41 | FileName = "dotnet", |
41 | 42 | Arguments = $"\"{photinoTestAppPath}\" --basic-test", |
42 | 43 | RedirectStandardOutput = true, |
| 44 | + RedirectStandardError = true, |
| 45 | + UseShellExecute = false, |
43 | 46 | }, |
44 | 47 | }; |
45 | 48 |
|
46 | 49 | photinoProcess.Start(); |
47 | 50 |
|
48 | 51 | var testProgramOutput = photinoProcess.StandardOutput.ReadToEnd(); |
| 52 | + var testProgramError = photinoProcess.StandardError.ReadToEnd(); |
49 | 53 |
|
50 | 54 | await photinoProcess.WaitForExitAsync().TimeoutAfter(TimeSpan.FromSeconds(30)); |
51 | 55 |
|
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 | + } |
55 | 76 | } |
56 | 77 | } |
0 commit comments