Adding Unit Tests to repo-context-packager
dev.to·5h·
Discuss: DEV
Flag this post

To add unit tests into my CLI tool I used Catch2, a modern C++ unit testing framework that makes writing tests easy and quick. It has a nice single-header option that you can drop into a repo, simple REQUIRE / CHECK macros, and flexible test naming and tagging. Also, Catch2 was the library I found interesting when I was looking at open-source projects during the first week of OSD600 cource, so I already liked it.

To write unit tests, I first created a tests/ folder in my project and added the Catch2 single-header file there. Then I wrote separate test files for different parts of my project, such as test_utils.cpp, test_file_reader_scanner.cpp, and `test_compressor.c…

Similar Posts

Loading similar posts...