Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Not using Rust myself I'll add to @InfiniteDissent's answer on: is there a better way to solve this problem altogether? Yes, there is, it's called a golden master test. Legacy code retreat t...
Answer
#1: Initial revision
Not using Rust myself I'll add to @InfiniteDissent's answer on: > is there a better way to solve this problem altogether? Yes, there is, it's called a golden master test. [Legacy code retreat](https://www.jbrains.ca/training/course/surviving-legacy-code) taught me [a golden master](https://www.codurance.com/publications/2012/11/11/testing-legacy-code-with-golden-master) testing technique for cases just like that. 1. You create a set of inputs for your application. 2. You capture a set of outputs for these inputs, creating working pairs: i1 -> o1, i2 -> o2, ... in -> on. **That is your golden master**. 3. For each change you should run all inputs and COMPARE the outputs with the golden master ones. For console-heavy apps I'd usually do the following: 1. make your CLI app accept an array of inputs (or a file with inputs). 2. have the app source inputs from said array/file. 3. capture the output by redirecting it to a file. 4. Assuming that we have 40 sets of inputs: `for i in $(seq 40); do ./app input$i > output$i; done; diffOutputsWithGoldenMaster.sh` 5. For diffing the outputs, sometimes just `diff` is enough (I always tried to make it so). Sometimes, you want something special, usually to highlight clearer the parts broken. In short: I'd move the testing outside of the Rust app. I had success with this technique also with SQL, where I wanted to make sure all reports worked before and after we completely overhauled the engine for their making, running and exporting. We had two Jenkins jobs, one for query generation (in your case, message creation) and one for actual results of the reports being the same (the console log of your app run) as the golden master. AFAIR, the name is from music recording, where the original, often golden CD, was "the master record", a collectors item. And the source of mass-production of CD albums.