@西蒙(https://stackoverflow.com/users/53158/simon)
在 docs 中提到了如何为
Verify
设置自定义输出目录,它工作得很好,但每次测试都这样做很痛苦。
await Verify("value")
.UseDirectory("CustomDirectory");
ApprovalTests 有一个全局的
UseApprovalSubdirectory
可以解决这个问题。所以我想知道VerifyTests/Verify中有类似的东西吗?相关 GitHub 问题:https://github.com/VerifyTests/Verify/issues/482
您应该能够使用 DerivePathInfo 来实现此目的。所以在你的情况下
VerifierSettings.DerivePathInfo(
(sourceFile, projectDirectory, type, method) =>
{
return new(
directory: Path.Combine(projectDirectory, "CustomDirectory"),
typeName: type.Name,
methodName: method.Name);
});