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

mihails.kuzmins
  • 1,140
  • 1
  • 11
  • 19

1 Answers1

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);
    });
Simon
  • 33,714
  • 21
  • 133
  • 202