approvals/ApprovalTests.Net

FileLauncherReporter Not Working in .NET Core 3.1 Test Project

jason-roberts opened this issue · 2 comments

Error message when verifying a .txt file with ApprovalTests 5.2.5 in a .NET Core 3.1 test project with xUnit.net 2.4.1 (Windows 10):

  Message: 
    System.ComponentModel.Win32Exception : The specified executable is not a valid application for this OS platform.
  Stack Trace: 
    Process.StartWithCreateProcess(ProcessStartInfo startInfo)
    Process.Start()
    Process.Start(ProcessStartInfo startInfo)
    Process.Start(String fileName)
    FileLauncherReporter.Report(String approved, String received) line 13
    FileApprover.ReportFailure(IApprovalFailureReporter reporter) line 65
    Approver.Verify(IApprovalApprover approver, IApprovalFailureReporter reporter) line 13
    Approvals.Verify(IApprovalApprover approver, IApprovalFailureReporter reporter) line 71
    Approvals.Verify(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter) line 52
    Approvals.Verify(IApprovalWriter writer) line 124
    Approvals.VerifyWithExtension(String text, String fileExtensionWithDot, Func`2 scrubber) line 189
    Approvals.Verify(String text, Func`2 scrubber) line 176
    HtmlReportGeneratorShould.Generate() line 37
[UseReporter(typeof(FileLauncherReporter))]
...
Approvals.Verify(someString);

The same code in a .NET framework 4.7.2 test project works correctly and opens the application associated with .txt files.

Rather than using Process.Start(received) you could maybe do?:

var p = new ProcessStartInfo(received);
p.UseShellExecute = true;
Process.Start(p);

@jason-roberts out of curiosity. why do u use FileLauncherReporter instead of DiffToolReporter?

@SimonCropp e.g. if you wanted to verify a generated sound/wav file (e.g. speech generation) or a rendered/generated video where a static diff/view wouldn't work