At work, I have a cohort, whom with I am convinced I share a brain. We recently embarked on a project to redesign and rewrite one of the core pieces of the application stack that we work one - it manages a hands-free modelling pipeline, based on configurations. A user of our app can make a configuration change, and this component reconciles those changes, runs the necessary background modelling tasks, and figures out when the model is ready to be used in production.
At its core, it is a state machine. We designed it like that at the start. However, through time and added features, it wasn’t implemented as a state machine, and became pretty unruly to debug or extend. We were adding a lot of new features in our upcoming release that just couldn’t be made to work in the existing code base - it was written too rigidly to accept that many things can happen from a singular “state”, each taking their own time - and started a rewrite into a full state machine. We’re a C# and .NET shop, so we found dotnet-state-machine/stateless, and it worked amazingly.
While we were doing the rewrite, however, we wanted to make sure we were not adding new bugs or regressions. The original codebase had only the bare minimum of automated tests, so we started with expanding them first.
Let’s talk about testing layers, how they interact, and how we used them to ensure our rewrite was a success