質問

I can't find out how to move the .approved. files to a folder of their own in Approval-tests. I guess the information is there somewhere - I just can't find it.

https://github.com/approvals/ApprovalTests.Net

役に立ちましたか?

解決

The current way to do it is by annotating the fixture or at the assembly level with

[ApprovalTests.Namers.UseApprovalSubdirectory("foldername")]

If you are before version 3.2 you can create a custom namer that will handle this if you want to. The basics are:

Override the namer for your framework, and override the method SourcePath

public string SourcePath
{
    get { return base.SourcePath + @"\yourSubfolder"; }
}

Then you need to add your new namer to the stack

StackTraceParser.AddParser(new MyNamer());

Although I would ask why you want the separation of the approval files to a subdirectory of your tests? I'm sure there is a good reason, but I have found it nicer to keep them closer to my actual tests.

他のヒント

From a look at the code from Git, it looks like Llewellyn just added the following attribute...

[UseApprovalSubdirectory("Approvals")]

.. to place the approvals in a subfolder called "Approvals". This appears to work at the test and class level.

This helps keep those approvals organized when there are many approval files for each unit test file.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top