-
i would like to setup some global settings and initialize modules. the only references i see are short snippets (example).
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
i found this section of the docs but its not clear. do i need to apply |
Beta Was this translation helpful? Give feedback.
-
after some experimentation here is what worked: note you do not need
using System.Runtime.CompilerServices;
namespace API.Test
{
public static class GlobalSnapshotConfig
{
public static readonly string SNAPSHOTS_BASE_DIR_NAME = "snapshots";
[ModuleInitializer]
public static void ConfigureVerify()
{
InitializeVerifyModules();
ConfigureSettings();
// https://github.com/VerifyTests/Verify/blob/main/docs/naming.md#derivepathinfo
DerivePathInfo(
(sourceFile, projectDirectory, type, method) =>
{
return new PathInfo(
Path.Combine(projectDirectory, SNAPSHOTS_BASE_DIR_NAME),
type.Name,
method.Name);
});
}
private static void ConfigureSettings()
{
// apply global settings
VerifierSettings.IgnoreStackTrace();
}
private static void InitializeVerifyModules()
{
// initialize modules
// VerifyDiffPlex.Initialize();
}
}
} |
Beta Was this translation helpful? Give feedback.
after some experimentation here is what worked:
note you do not need
[UsesVerify]
like in the example unless you use XUnit. for NUnit this annotation wasnt even available