3

I've been using approval-tests for a while with the WinMergeReporter and it is working well with the standard NUnit runner executable.

I am trying out NCrunch and the approval.Verify fails (as expected) for a new approval.

However, WinMerge does not startup.

I get the failure

ApprovalTests.Core.Exceptions.ApprovalMissingException : Failed Approval: Approval File "...\mytest.approved.txt" Not Found. at ApprovalTests.Approvers.FileApprover.Fail()

I can run the same code in the NUnit runner and WinMerge starts up.

What's the secret sauce for NCrunch to bring up the WinMergeReporter?

James Bradt
  • 564
  • 5
  • 11

1 Answers1

8

This is actually by design, as having winmerge pop up every time NCrunch fails gets very annoying very quickly. Especially as it steals focus.

However, here's why it works and how to change it, if you so desire (you can always change it back)

Approval Tests has a MultiReporter system it uses that Front Loads from the assembly to implement the GangOfFour "Chain of Responsibility" pattern. It will act as if there is a

[assembly: FrontLoadedReporter(typeof(NCrunchReporter))]

This does not actually have to be there. Approval Tests will assume it as the default if nothing is actual present.

So if you wanted to turn it off you could just do

[assembly: FrontLoadedReporter(typeof(AlwaysFaillingReporter))]

Except that reporter doesn't exist (although it would be trivial to make one :-) So you might just want to do

[assembly: FrontLoadedReporter(typeof(WinMergeReporter))]

Happy testing!

llewellyn falco
  • 2,281
  • 16
  • 13
  • 1
    Thanks for the quick response. You are correct that I probably don't want the WinMergeReporter running all the time, but there are times it comes in handy to have this 'just work'. On my dev machine, I've set up WinMerge to use an running instance (setting is inside WinMerge) and I have WinMerge open on a different monitor. So, if I get a lot of approvals, they all line up within one WinMerge session as different tabs. So far, it works pretty well – James Bradt Jul 27 '12 at 18:50
  • Nice, I didn't realize WinMerge had that option, I'll have to try that out. – llewellyn falco Jul 31 '12 at 13:17
  • It wasn't completely clear to me, so I'll mention that goes in the AssemblyInfo (or any file) for the Test Assembly, not the SUT. WinMerge also has a single-instance switch, which you may want to enable or disable as you prefer. If you uncheck it and you have multiple failures, you'll get on WinMerge for each mismatch. – Wade Hatler May 23 '14 at 04:35