This week's lab has to do with testing which is something I've done a fair bit of. The first 8 months of this year I was in a work placement doing manual QA work for the Ministry of Children, Community and Social Services. I got a lot of hands on experience, but the videos for this week helped fill in a lot of gaps in the theory side of things, words I'd heard of like "coverage" for example that I hadn't been able to fully contextualize and define, so it's been cool hearing more about the theory behind testing.
For my part I added some testing capabilities to my SSG using Catch2. Catch2 was super easy to set up and involved downloading one header file from their github repo and including it in my program. There are a number of ways you can choose to have Catch interact with your project, either by having Catch define your main i.e
#include "catch.hpp"
#define CATCH_CONFIG_MAIN
or by supplying your own a la
#include "catch.hpp"
#define CATCH_CONFIG_RUNNER
I opted for the former, refactoring my program in the process to have the main be compiled separately from the testing capabilities (by only having catch included in the testing translation unit I avoid adding the lengthy compile time that results from its inclusion for non-developer use of the SSG) This was probably the hardest part as I went back and forth trying to decide how I should structure my program to take advantage of Catch without having some weird structural choices arise from it. I ended up refactoring it over several times but I think the way I landed on makes the most sense.
I added a test.cpp
to write tests in and wrote unit tests for all the functions used throughout my SSG. I ran into issues from my functions not running properly outside of my main, not sure what that's about but they work as expected when called in their normal context. Finally, I merged my changes and updated the documentation to reflect the new addition.
Top comments (0)