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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help