C++ Unit Testing Fundamentals Using Catch

Writing unit tests is a big part of being a professional software developer. This course would teach you how to write readable and robust unit tests using Catch, a simple, yet powerful unit testing framework.
Course info
Rating
(58)
Level
Beginner
Updated
Oct 21, 2016
Duration
1h 38m
Table of contents
Course Overview
Introducing Catch
Organizing Your Tests Using Catch
Asserting Using Catch
Handling Duplicate Code
Description
Course info
Rating
(58)
Level
Beginner
Updated
Oct 21, 2016
Duration
1h 38m
Description

Writing unit tests is a big part of being a good software developer. Unfortunately, unit testing in C++ is far from being trivial and good unit testing frameworks are hard to find. In this course, C++ Unit Testing Fundamentals Using Catch, you will learn how to write robust unit tests using Catch, a simple-to-use, yet flexible and powerful unit testing framework for C++. You will learn what makes Catch different from other xUnit frameworks, and how it can be used to write unit tests for your C++ code. You will also get to see how to run Catch from the command line, how to use test fixtures, and how to create maintainable tests. When you're finished with this course, you will have a foundational knowledge of Catch and unit testing in C++ that would help you create better, cleaner C++ code.

About the author
About the author

Dror is a Software developer, architect, and consultant who likes to help software developers write better code. He's a public speaker and blogger. Dror teaches, mentors, and writes code using clean code principles, TDD, and BDD.

More from the author
AWS Developer: Lambda Deep Dive
Intermediate
3h 18m
Jul 2, 2018
Advanced C++ Mocking Using Google Mock
Intermediate
3h 49m
May 19, 2017
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name is Dror Helper and welcome to my course C++ Unit Testing Fundamentals Using Catch. I'm a software developer, architect, and a consultant who cares about his code and enjoys teaching other developers how to write better code. This course is not about yet another unit testing framework, it's about writing good unit testing C++, because I found out that writing readable, sustainable and robust unit tests is crucial for successful software development. In this course we are going to learn how to write good robust unit tests using Catch, a simple to use yet powerful and flexible unit testing framework for C++. Some of the major topics that we will cover include what makes CATCH different from other unit testing frameworks and in fact what makes it better than other unit testing frameworks? How to write good unit tests and what does it mean a good unit test? How to run your tests from command lines using Catch and using special tags, and why we care about test failures and how to get the most out of them, and finally we'll talk about how to reduce duplicate code in your unit tests while maintaining readability. By the end of this course you'll know how to write unit tests in C++ using CATCH in order to create better and cleaner C++ code. Before beginning this course, you should be familiar with C++, so in case you need a refresher, check out one of the excellent C++ Pluralsight courses on the subject. I hope you'll join me in this journey to learn all about unit testing and what makes Catch an excellent unit testing framework with the C++ Unit Testing Fundamentals Using Catch course at Pluralsight.

Introducing Catch
Hello, my name is Dror Helper and this is the C++ Unit Testing Fundamentals Using the Catch framework course. In this course we'll talk about unit testing, how to write them, best practices, and how to use the Catch unit testing framework in order to write readable and maintainable tests. Unit testing has become an important factor in any software project's success. It enables us to write better code faster and without compromising quality. What I like about Catch is that it helps developers write good unit tests with its simple yet powerful API. In this course I am not only going to show you how to use Catch to write unit tests, I will also explain about best practices and consideration when using unit tests and how Catch helps us achieve those goals.

Asserting Using Catch
Hello, I am Dror Helper and this is the C++ Unit Testing Fundamentals Using Catch Course. In this module we're going to dive into Catch assertions, but before we start, I'd like to clear something up. Although Catch does not have the word assert as part of its API, I still think that the verification in which you check the test results is in fact a form of assertion, so even if in Catch it's called require or check or whatever, I will still refer to the act of checking whether the test passed or failed as an assert or assertion throughout this module. This module is all about checking the test results. We'll discuss why it's crucial to have a good failure messages and how to verify that a test passed or more importantly how to understand why a test failed. I'll discuss why you should care about unit test assert and how properly use REQUIRE to create readable and easy to maintain unit tests. Then I'll talk about multiple assert _____ and discuss why multiple asserts are required in one test can be a problem and how to solve that problem. Afterwards I'll show a Catch help us write test that checks that an exception occurred in that specific test, which doesn't happen a lot, but when it does you want to write a test the right way. And lastly I'll show how to add more information to unit test failure using Catch. As well as how to make your test result provide more information when a test fails by customizing how your objects and type look like in a test failure. But before that, let's have a quick reminder of REQUIRE and asserts in unit tests.

Handling Duplicate Code
Hello, I'm Dror Helper and this is the C++ Unit Testing Fundamentals Using Catch course. In this module we'll cover how Catch helps us reduce duplication, create maintainable and readable unit tests. Before we start I'd like to state that code duplication in a test is not necessarily evil, in fact sometimes it's okay to create new tests by copying and modifying an existing test, yet in other times code duplication creates maintenance hell and should be avoided. We'll try to understand when each of them apply. We'll start by discussing when code duplication happens in automated tests, then cover the DRY and DAMP principles that guide us when writing new tests. From there we'll dive into Catch capabilities starting with Fixtures, just like most unit testing framework out there, follows by catching _____ take on test reusability using sections. And lastly, I'll introduce BDD briefly and explain how Catch enables writing BDD-like tests.