Build/Test Issues

ApprovalTest

Started by bhugot on 1,948 views

Hello I have an issue when using approval test with ncrunch.
Ncrunch restart testing permanently.
I think it's due to the generation of .received file, I have put *.received.* in FilesExcludedFromAutoBuild but it's keep runing.

To reproduce it. I have created a simple nunit test project with this class only

public class Tests
{
[Test]
[UseReporter(typeof(DiffReporter))]
public void Test1()
{
Approvals.VerifyJson("{}");
}

[Test]
[UseReporter(typeof(DiffReporter))]
public void Test2()
{
Approvals.VerifyJson("{}");
}
}

Regards

Edited

Hi, thanks for posting.

This problem is caused by the approvals tests output files being implicitly included in the project file. When approvals creates the files, this changes the list of files included in the project, forcing NCrunch to reload it. If you have the engine set to run all tests automatically, this can result in circular behaviour as the engine will re-queue the tests for execution.

The solution is to ensure the approvals tests output files are excluded from the project. You can do this using a wildcard in the DefaultItemExcludes property inside the project. For example:

<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);*.received</DefaultItemExcludes>
</PropertyGroup>
Thanks alot

Post a reply

Log in to reply.