Start a C++17 coding kata with Catch2 v2. Setup is complete when the starter test passes.
This is a bootstrap repository for clean code katas in C++17 using Catch2.
Required:
- Git
- A compiler with C++17 support. Choose one:
- GCC 10+ on Linux
- LLVM Clang 14+ on Linux
- Apple Clang 17+ on macOS
- MSVC 2022 on Windows
- CMake 3.24 or later
Optional:
- GNU Make, for shorter commands. Every required task also has direct CMake and CTest commands. Make may be unavailable on Windows.
You do not need to install Catch2 separately. CMake finds an installed Catch2 v2 package or downloads the pinned v2.13.10 release when needed.
-
Clone the repository:
git clone https://github.com/Coding-Cuddles/bootstrap-cpp-catch2.git -
Enter the repository directory:
cd bootstrap-cpp-catch2 -
Run the starter test. Use Make when it is installed:
make testOtherwise, use CMake and CTest directly:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug cmake --build build --config Debug ctest --test-dir build --build-config Debug --output-on-failure
The first run may download and build Catch2. CTest should report
100% tests passed.
If a command reports a missing compiler or CMake, install that prerequisite and run the setup commands again.
Setup is complete when CTest reports 100% tests passed.
-
Replace the starter assertions in
test_something.cppwith the first kata test. -
Run the tests after each change. Use Make when it is installed:
make testOtherwise, use CMake and CTest directly:
cmake --build build --config Debug ctest --test-dir build --build-config Debug --output-on-failure
Continue when CTest reports
100% tests passed.
Make is optional. Run make or make help to list these commands in the
terminal.
| Command | Result |
|---|---|
make all |
Build and run the test suite |
make help |
Show the Make command reference |
make build |
Configure and build without running tests |
make run |
Build and run the main executable |
make test |
Build and run the test suite |
make format |
Format tracked C++ and header files |
make format-check |
Check formatting without changing files |
make clean |
Remove generated build artifacts |