How do I get NCrunch to stop launching the DiffReporter when it is running tests in the background, but easily get the DiffReport when I manually run a test?
I've been trying to get this working for a while now, but none of the combinations I've tried are giving me the results I'm looking for. I am currently leaving the [UseReporter(typeof(DiffReporter))]
attribute commented out. When a test starts failing I will come back and un-comment it until I fix the issue, then comment it back out, but this is getting especially cumbersome for methods with multiple [TestCase]
. From what I've been reading on the ApprovalTests blog, it seems like this should be possible.
My diff software is Beyond Compare, and my code currently looks like this:
TestProject/AssemblyInfo.cs
[assembly: UseReporter(typeof(NCrunchReporter))]
TestProject/ClassTests.cs
public class ClassTests
{
[Test]
//[UseReporter(typeof(DiffReporter))]
[TestCase(1, 1)]
[TestCase(1, 2)]
[TestCase(2, 1)]
[TestCase(3, 1)]
public void TestCase(int errorNumber, int )
{
using (ApprovalResults.ForScenario(errorNumber, testCaseSubtestNumber))
{
var results = DoSomething();
Approvals.Verify(results);
}
}
}
Update:
I'm using the following NuGet packages:
- ApprovalTests v3.0.11
- ApprovalUtilities v3.0.11
- NUnit v3.2.1
It should be the default behavior. The actual code you want is
[assembly: FrontLoadedReporter(typeof(NCrunchReporter))]
But NcrunchReporter is part of the DefaultFrontLoadedReporter. These reporters go in front of any reporter you use and block if the situation is detected.
Perhaps NCrunch has changed though. Could you try running this via NCrunch and reporting the results
Approvals.SetCaller();
Assert.IsTrue(NCrunchReporter.INSTANCE.IsWorkingInThisEnvironment("a.txt"));
It should be true, if it is not NCrunch has changed and we will need to update the reporter accordingly.