C++ Unit Testing: Google Test and Google Mock
4.2 (40 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
188 students enrolled

C++ Unit Testing: Google Test and Google Mock

Beginning Test Driven Development (TDD) in C++ with Googletest and Googlemock
4.2 (40 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
188 students enrolled
Created by Serban Stoenescu
Last updated 6/2020
English
English [Auto]
Current price: $62.99 Original price: $89.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 3 hours on-demand video
  • 5 articles
  • 15 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Google Test (C++ Unit Testing)
  • Google Mock
Requirements
  • Basic C++
  • No unit testing experience is required
Description

This course is for software developers and students who want to be better programmers by writing more solid, bug-free code using the Google Test framework.

Your code will get better and you will have more confidence that your code is correct, because you will catch more bugs using automated tests.

How many times did this happen to you? You wrote new code, and after your hard work is done, you find that you broke features that used to work? And you had to waste more hours finding and fixing the bugs... This problem can get solved in most cases by using automated tests, especially unit tests.

No experience with automated testing is required. Very basic C++ knowledge is needed, nothing too sophisticated.

If you are completely new to Google Test, this course is just for you! If you already have some knowledge, look at the course content and see if you find some more advanced features that you didn't know about.

Google Test works on multiple platforms. You can use any platform you like. In this course, I am doing it on:

  • Windows (Visual Studio)

  • Linux (CMake or compiling directly from the command line)

  • Other platforms will be added if you suggest them to me

There are slides and hands-on coding examples in each section. I recommend that you try the examples and play around with them.

Here's a brief presentation of the course content:

  • Optional videos: Setting up on Windows (Visual Studio) and on Linux (CMake and GCC)

  • Basics of unit testing:

    • Unit test structure

    • Assertions - numeric, string, exceptions

  • Reusing code between tests (test fixtures, SetUp() and TearDown())

  • Parameterized tests:  generate multiple tests by writing one single function.

  • Mocking - replacing real objects with fakes that you can control):

    • Basics

    • Setting the behaviour of mocks

    • Matchers

Who this course is for:
  • Software developers and students who want to make their code more robust, bug-free
  • Anyone interested in Google Test and Google Mock
Course content
Expand all 50 lectures 02:51:10
+ Setting Up Google Test
6 lectures 31:14
Installing Visual Studio
04:25
Visual Studio - Sample GTest Project
07:48
Installing on Linux
03:43
Google Test CMake Sample (Linux)
07:14
Google Test - CMake With a Test Runner and Actual Application
06:02
+ Unit Testing Basics
14 lectures 28:02
What is a Unit Test?
01:15
Unit Test Characteristics
01:03
Types of Testing
01:37
Unit Test Structure (Slides)
01:44
Unit Test Structure (Code Example)
04:20
Assertions
01:49
Assertions (Code Example)
01:46
Assertions on Strings - Wrong Way To Do It
05:42
Assertions on Strings
01:04
Assertions on Strings (Code Example)
02:05
Assertions on Exceptions
00:49
Assertions on Exceptions (Code Example)
03:47
Summary
00:25
Basics Quiz
4 questions
+ Fixtures: Remove Redundant Code
7 lectures 30:10
Fixture Flow
02:21
Parameterized Tests
01:45
Parameterized Tests (Code Example)
12:36
Summary
00:22
Fixtures Quiz
4 questions
+ Setting Up Google Mock
3 lectures 15:38
Intro
00:27
Google Mock Visual Studio (Windows)
07:34
Google Mock CMake Sample (Linux)
07:37
+ Google Mock
15 lectures 55:12
Mocking Project Resources
00:33
Introduction to Mocking
01:54
Mocking Methods
02:14
Presentation of Our Project
05:28
Mocking Methods - Current Way (Code Example)
09:36
Mocking Methods - Legacy (Code Example)
04:10
Setting Expectations and Behaviour
01:47
Mocking - Times (Code Example)
03:39
Mocking - Returns (Code Example)
03:17
Invoking Actions (Code Example)
08:48
Matchers
01:38
Matchers (Code Example)
06:35
Assertions on Vectors (Code Example)
04:06
Summary
00:24
Mocking Quiz
6 questions
+ Bonus: Tips & Tricks
3 lectures 09:56
What's this?
00:08
Running a subset of tests, FAIL() and SUCCEED()
07:08

We also have a quick look at what other projects related to Google Test exist.

Visual Studio Test Runner
02:40