I’m working on making a
Route type which can be used throughout my project to refer to the possible routes in my frontend and convert them to/from URLs. A common sanity check/test for this kind of thing is to try “round-tripping” routes through the to-URL/from-URL functions to ensure everything is covered and consistent. So I wrote a fuzzer for my
Route type, which was straightforward.
I expect this type will change as I add pages to my project. When this happens, I will have to remember to update the fuzzer. If I don’t, my test will become invalid because the new cases I added will not be tested in the round trip.
Has anyone come up with a clever way to ensure that the fuzzer stays in sync with the underlying type? One idea I had was to add a dummy
reminder function just under the fuzzer which does an exhaustive pattern match on the
Route type. Then, if a constructor is added, at least the
reminder function will break, and hopefully that will serve as a reminder to update the fuzzer. But maybe there’s another way?
Is this a non-issue for other people, perhaps because you keep your fuzzers closer to the underlying type (as hinted at in e.g. Where to put encoders, decoders and generators?)?