GildedRose-Refactoring-Kata/cpp/README.md
tbeu 3bf108ef0e Restructure build targets of CMake configuration
* Rename the library under test from src to GildedRoseLib.
* Move the lib folder to test/third_party and handle ApprovalTests.hpp as header-only dependency.
* Remove the superfluous googletest_approval_main.cpp (in the same sense as there is only one GildedRoseCatch2ApprovalTests.cc)
* Set USE_FOLDERS property such that target ALL_BUILD, RUN_TESTS and ZERO_CHECK are grouped for Visual Studio.
* Set WORKING_DIRECTORY such that the RUN_TESTS target works successfully.
* Fix C++ language standard for Catch2 v3 to C++14.
* Bump third-party dependencies
  * Update ApprovalTests.hpp to v10.13.0
  * Update Catch2 to v3.8.0
  * Update GTest to v1.16.0
2025-02-11 23:04:23 +01:00

69 lines
2.5 KiB
Markdown

# C++ version of Gilded Rose refactoring kata
## Introduction
The C++ version of the Gilded Rose refactoring kata is available in four variants using different test frameworks:
* Catch2 test framework
1. Traditional unit test with the [Catch2](https://github.com/catchorg/Catch2) test framework in the `test/cpp_catch2_unittest` folder.
2. [Approval tests](https://github.com/approvals/ApprovalTests.cpp) with the [Catch2](https://github.com/catchorg/Catch2) test framework in the `test/cpp_catch2_approvaltest` folder.
* Google Test framework
1. Traditional unit test with the [Googletest](https://github.com/google/googletest) test framework in the `test/cpp_googletest_unittest` folder.
2. [Approval tests](https://github.com/approvals/ApprovalTests.cpp) with the [Googletest](https://github.com/google/googletest) test framework in the `test/cpp_googletest_approvaltest` folder.
The `GildedRose.cc` file, i.e. the code under test, is identical in all four variants.
## Prerequisites
* CMake version >= 3.13
* C++ compiler that supports C++14
## How to build and run tests in a terminal
### Build tests
$ cd ${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .
### Show available tests
$ cd ${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp/build
$ ctest -N
Test project ${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp/build
Test #1: GildedRoseCatch2ApprovalTests
Test #2: GildedRoseCatch2UnitTests
Test #3: GildedRoseGoogletestApprovalTests
Test #4: GildedRoseGoogletestUnitTests
### Run all tests
$ ctest
### Run all tests with verbose output
$ ctest -VV
### Run a specific test with verbose output
$ ctest -VV --tests-regex Catch2Approval
## How to build and run tests using the [CLion IDE](https://www.jetbrains.com/clion/)
1. Start CLion
2. Select menu `File - Open...`
3. Select folder `${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp`
4. Select menu `Build - Build Project`
4. Select menu `Run - Run...`
4. Select what test variant to run, e.g. `GildedRoseCatch2ApprovalTests`.
## How to build and run tests using Visual Studio 2019
1. Start Visual Studio 2019
2. Select `Open a local folder`
3. Select folder `${GIT_FOLDER}/GildedRose-Refactoring-Kata/cpp`
4. Wait for message `CMake generation finished.` in the CMake output window at the bottom
5. Select what test variant to run in the drop down menu for Startup Items, e.g. `GildedRoseCatch2ApprovalTests.exe`.
6. Select menu `Debug - Start`