# Catch2 - Testning i C++

Nivå: intermediate | Målgrupp: C++ programmerare | Förkunskaper: Vana att programmera i C++
https://www.ribomation.se/programmerings-kurser/catch2/

Catch2 är vår egna favorit vad gäller enhetstester för C++ program.
Det går enkelt att skriva testfall i <em>given/when/then</em> stil.

Skriv inte en rad produktionskod utan att ha ett tillhörande enhets-test. I denna kurs går vi rakt på sak och
lär dig hur du använder Catch2 för att skriva genomtänkta enhetstester.

Catch2 är vår egna favorit vad gäller enhetstester för C++ program. Skälet är flera; Det är header-only vilket
innebär bara en fil att ladda ned. Det går enkelt att skriva testfall i given/when/then stil. Det går enkelt
att nästla test funktioner, vilket på ett elegant sätt eliminerar behovet av test fixture klasser, vilket finns
i många andra test ramverk.

- Install and configure Catch2
- Write effective device tests
- Handle test data in nested test cases
- Be able to formulate test conditions and output comparators
- Write parameterized tests
 

#### Unit Testing and TDD
-    Type of tests
-    What is a unit test
-    Write F.I.R.S.T. tests
-    Structure of a unit test
-    Given-when-then style
-    What is test driven development (TDD)

#### Installation of Catch2
* Catch2 at GitHub
* Download the header-only library
* How to automatically download and configuration using CMake
* Configuration of CLion to run Catch2

#### Writing a Test Function
* Including Catch
* Defining a test runner
* Structure of a test function
* Usage of REQUIRE()
* Analyzing a failed test

#### Assertions
* REQUIRE vs. CHECK macros
* Dealing with floating-point comparisons
* Asserting exceptions
* Logging

#### Matchers
* What is a matcher?
* Using REQUIRE_THAT()
* String matchers
* Vector matchers
* Floating-point matchers
* Predicate lambda matchers
* User-defined matchers

#### Test Fixtures
* Defining a test function with nested SECTION blocks
* Defining test data (fixture)
* How nested test cases are executed and handed test data
* Tagged test cases
* Special tags

#### Scenarios and BDD-Style Test Cases
* Defining a SCENARIO
* Defining a test case using GIVEN / WHEN / THEN
* Conjunctions

#### Parameterized Tests
* Defining a TEMPLATE_TEST_CASE
* Type-parameterized tests
* Test-data generators
* Value generators
* Predicate-based generators
* Random value generators
* User-defined generators

#### Micro Benchmarks
* What is a benchmark?
* Enable benchmarking
* Defining a BENCHMARK

#### Configuration
* Writing your own main() function
* Command-line options
* Invoking the test runner
* Compile-time configuration properties
* Command-line options
* Log reporters
* CMake integration
