Custom verified file suffix and option to use same file name but different extension per test
Situation
We have a big project with a thousand tests and a few thousand approved files.
We previously used ApprovalTests and migrated to VerifyTests.
Problems
- Changing from
.approved.to.verified.will cause a lot of conflicts and changes that we are trying to avoid. - We have tests that use the same name but have different extensions but in VerifyTests it's not possible because the search for verified files does not include an extension (Verify considers another file with a different extension as an excess file).
Proposed solution
- Global setting to set the custom suffix instead of '.verified.'.
- Setting that is possible to set per test using a specific extension otherwise searching for all verified files.
I'm more than happy to create PR for this if this request is acknowledged and agreed.
We have tests that use the same name but have different extensions but in VerifyTests it's not possible because the search for verified files does not include an extension (Verify considers another file with a different extension as an excess file).
can you share some example tests for this scenario?
We have tests that use the same name but have different extensions but in VerifyTests it's not possible because the search for verified files does not include an extension (Verify considers another file with a different extension as an excess file).
can you share some example tests for this scenario?
This is an example unit test for such scenario.
[Fact]
public async Task SameFileNameButDifferentExtension()
{
VerifierSettings.DisableRequireUniquePrefix();
await Verify(
new[]
{
new Target("txt", "data one", "sameName")
});
await Verify(
new[]
{
new Target("json", "data two", "sameName")
});
}
try this instead
public async Task TheTest()
{
await Verify(
new[]
{
new Target("txt", "data one", "sameName"),
new Target("json", "data two", "sameName")
});
}
So about the second problem: we do not have many of those tests so we will make the test name unique. But what about the first problem: should I provide PR for that global setting?
Changing from .approved. to .verified. will cause a lot of conflicts and changes that we are trying to avoid.
re the conflicts, i dont understand how there would be any
re the changes. why is this a problem it is a once off change, and then you move forward. it is also a trivial change to make given you can bulk approve the new files