Skip to content

Expected data generation #1668

@binarycow

Description

@binarycow

Is the feature request related to a problem

I'm working on a tool that replicates some behavior in another tool (in a non-dotnet language). I have unit tests that ensure that given the same inputs, my tool and the other tool should produce the same results (text file).

In my test project, I have a C# method that executes that tool (via Process.Start) to generate the "expected" data.

I would like to use Verify, and remain using the external process to generate the expected data, but also leverage Verify to cache that expected data.

It is unlikely that the expected data will change, once it's generated.

Describe the solution

Before:

[Test]
public async Task TestSomething(string inputA, string inputB)
{
    var actual = RunMyTool(inputA, inputB);
    var expected = await RunExternalTool(inputA, inputB);
    Assert.That(actual, Is.EqualTo(expected));
}

After:

[Test]
public async Task TestSomething(string inputA, string inputB)
{
    var settings = new VerifySettings();
    settings.ExpectedDataGenerator = async () => await RunExternalTool(inputA, inputB);
    var actual = RunMyTool(inputA, inputB);
    return Verify(actual);
}

Describe alternatives considered

  1. Manually generate the expected data, each time I add new unit tests
  2. I don't know!

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions