davezych / shience

A .NET port(ish) of Github's Scientist library. (https://github.com/github/scientist)
MIT License
9 stars 1 forks source link

Testing write operations #9

Closed MovGP0 closed 8 years ago

MovGP0 commented 8 years ago

We should think about when and how to properly test write operations.

Ie. when there are two different databases (one production and one test) and the write goes to different databases, then the comparer needs to check if the result in both databases is identical.

There could be extension methods that support this scenario by also providing (async) read operations:

science
    .TestWrite(
        control: () => OldClass.WriteToOldDatabase(importantInformation), // returns void
        candidate: () => NewClass.WriteToNewDatabase(importantInformation) // returns void
    ).Test(
        control: () => OldClass.ReadFromOldDatabase(importantInformation),
        candidate: () => NewClass.ReadFromNewDatabase(importantInformation)
    );

Async version:

await science
    .TestWriteAsync(
        control: () => OldClass.WriteToOldDatabaseAsync(importantInformation), // returns void
        candidate: () => NewClass.WriteToNewDatabaseAsync(importantInformation) // returns void
    ).TestAsync(
        control: () => OldClass.ReadFromOldDatabaseAsync(importantInformation),
        candidate: () => NewClass.ReadFromNewDatabaseAsync(importantInformation)
    );
davezych commented 8 years ago

Write operations are... scary. I'm not sure whether they should be supported or not. The consensus on Scientist was to not experiment on write operations, rather always write with an old operation and then experiment on reads.

MovGP0 commented 8 years ago

Well, we better leave it then for now, until someone comes up with an better idea.