VerifyTests / Verify

Verify is a snapshot tool that simplifies the assertion of complex data models and documents.
MIT License
2.47k stars 138 forks source link

Breaking: Respect NUnit class level parameters and drop support for custom TestName #1249

Closed SimonCropp closed 1 month ago

SimonCropp commented 2 months ago

Who is effected

Changes:

No longer respect TestFixture.TestName and `TestCase.TestName

Reasons

Respect fixture level parameters and ignore NUnit fixture name convention

Previoulsy fixture level parameters were properly not respected by Verify. Verify would rely on NUnit convention for the fixture name. For example

[TestFixture("2", TestName = "CustomClassName")]
public class ClassLevelParams(string classParam)

The NUnit fixture name would be ClassLevelParams(1). While unique enough for the verified file it has several problems

Sample

[TestFixture("1")]
[TestFixture("2", TestName = "CustomClassName")]
public class ClassLevelParams(string classParam)
{
    [TestCase("3")]
    [TestCase("4", TestName = "CustomClassName")]
    public Task Test(string methodParam) =>
        Verify("Value");

Result

Before

ClassLevelParams(1).CustomClassName_methodParam=4.verified.txt
ClassLevelParams(1).Test_methodParam=3.verified.txt
CustomClassName.CustomClassName_methodParam=4.verified.txt
CustomClassName.Test_methodParam=3.verified.txt

After

ClassLevelParams.Test_classParam=1_methodParam=3.verified.txt
ClassLevelParams.Test_classParam=1_methodParam=4.verified.txt
ClassLevelParams.Test_classParam=2_methodParam=3.verified.txt
ClassLevelParams.Test_classParam=2_methodParam=4.verified.txt

Migration

After upgrading, the recommended approach is to treat the old verified files as Orphaned verified files.

tom-englert commented 1 month ago

👍 ❤️