approvals/ApprovalTests.Net

Not launching merge tool on failed approval

henebb opened this issue · 5 comments

Hi!

Working on .NET 4.7.2 with xUnit. Using version 5.4.2 of ApprovalTests (but haven't worked in previous releases either).
On failed approvals the merge tool is not launched, instead the diff tool is launched. Which is quite frustrating 🙂
To work around this I have created a custom diff reporter that looks like this (for p4merge):

public class CustomDiffReporter : IApprovalFailureReporter
{
	public void Report(string approved, string received)
	{
		if (!File.Exists(approved))
		{
			File.Create(approved);
		}
		var process = new System.Diagnostics.Process
		{
			StartInfo =
			{
				UseShellExecute = true,
				FileName = "C:\\Program Files\\Perforce\\p4merge.exe",
				Arguments = $"{approved} {received} {received} {approved}"
			}
		};
		process.Start();
	}
}

Not sure if that is helpful information? Happy to provide more info to clarify.

p4 merge should be supported OOTB https://github.com/VerifyTests/DiffEngine/blob/master/docs/diff-tool.md#p4merge

can u try the current release with the default DiffReporter and then set you preferred tool order

p4merge works. But it's launching the diff view, and not the merge view. When a test fails it would be nice if the merge view is launched so that you are able to impact the approval file.

I think line 8 needs to be $"\"{temp}\" \"{target}\" \"{target}\" \"{temp}\""; It works on Mac, but I'm not on a Windows machine currently. So can't verify it there.

deploying now