Testing Automation

I built Sleuth (GitHub - ruth-tirusew/sleuth: experimental... · GitHub), a Go CLI tool for running integration and scenario flows defined in declarative YAML.

I built it to solve a few specific headaches I ran into with API integration testing:

  • Silent API Drift: Endpoints changing payload shapes without breaking standard assertions.

  • Complex Step Dependencies: Having to manually sequence steps in YAML instead of letting a graph handle execution order.

  • Database Verification: Wanting to verify database side-effects mid-flow without risking accidental writes or state pollution.

I’m still experimenting with the idea and open to collaborations please do let me know what you think

I had a look through the repo, especially the behavioural snapshot tests. I think that part is pretty interesting, since API changes that don’t break existing assertions can be surprisingly easy to miss.

One thing I’m curious about is how you’d recommend handling snapshot merging in a larger project.

From what I understand, -merge can expand the accepted response shape based on multiple successful runs. That makes sense for fields that are genuinely optional, but I wonder if it could also make unexpected API changes harder to catch over time, especially when different environments or API versions are involved.

Maybe keeping separate baselines per environment or API version would help? I’m not entirely sure what the best approach would be here.

I haven’t run the CLI yet, so this is more of a question from reading the implementation and tests than a bug report.

I’d be interested to hear how you see teams managing those snapshots in CI once they have quite a few flows.

Thanks for the close read. You’re right about -merge: it only ever loosens a snapshot, so merging in a run from a bad environment or an old API version means the snapshot then accepts that shape.

What I’d recommend:

  • Keep one snapshot per environment and API version, for example snapshots//checkout.json, and compare each environment against its own baseline. Today that’s done by file naming. Native per-environment support isn’t built yet beyond recording the environment in the file.
  • Use -merge only for several known-good runs of the same flow against the same target. That’s what it’s for: learning which fields are really optional. Don’t merge across environments that should behave differently.
  • Keep recording and merging out of CI. CI should only compare, with -shapes FILE -shape-drift-fail breaking. Recording refuses to overwrite a snapshot that differs, and -force keeps a .prev copy. Snapshot updates then show up as a reviewed git diff.
  • Treat required-to-optional changes as something to review. Use assertions and contracts for the fields that must always be present.
1 Like

I think your “kind” field is superfluous. kind: “db” is directly followed by “db: …” so it is redundant and prone to break on copy & pasting or editing.