0

@Simon (https://stackoverflow.com/users/53158/simon)

In the docs it is mentioned how to setup a custom output directory for Verify and it works fine, but it is pain to do it for every test.

await Verify("value")
    .UseDirectory("CustomDirectory");

ApprovalTests have a global UseApprovalSubdirectory which solves this issue. So I wonder is there anything similar in VerifyTests / Verify?
The reason is that VS2022 does not allow renaming nested files, so I need to go to the file explorer and rename files there (pain...)

Related GitHub issue: https://github.com/VerifyTests/Verify/issues/482

4

1 回答 1

1

you should be able to use DerivePathInfo to achieve this. So in your case

VerifierSettings.DerivePathInfo(
    (sourceFile, projectDirectory, type, method) =>
    {
        return new(
            directory: Path.Combine(projectDirectory, "CustomDirectory"),
            typeName: type.Name,
            methodName: method.Name);
    });
于 2022-02-24T19:24:07.190 回答