Advanced C++ Mocking Using Google Mock 1
Writing unit tests is not trivial. In this course, you'll learn how to succeed using a powerful tool, Google Mock. It has become the standard mocking framework for C++ developers who want to write high quality code faster.
What you'll learn
Writing unit tests looks simple in blogs, books, and tutorials. However, it can be quite difficult when attempted in the real world where real code has dependencies that make unit testing difficult. The solution is to isolate unit tests using mocks, stubs, and fakes. Using mocks is crucial for any developer who attempts to unit test his code. In this course, Advanced C++ Mocking Using Google Mock, you'll learn how to fake dependencies in C++ using Google Mock. First, you'll learn about how to make unit tests simpler and more predictable using mocks. Next, you'll explore how to run Google Mock with different unit testing frameworks, and cover mocking frameworks best practices. Finally, you'll learn useful unit testing patterns for existing legacy code. By the end of this course, you'll have a working knowledge of mocking frameworks and Google Mock, and you'll be able to efficiently unit test any code.
Table of contents
- Version Check 0m
- Course Introduction 1m
- Who Is This Course For? 2m
- Course Overview 2m
- Introducing Google Test 4m
- Understanding Real-world Unit Testing Issues 5m
- Introducing Google Mock 3m
- Getting Started with GTest and GMock 2m
- Demo: Getting Started with GTest 4m
- Writing Tests Using GTest 1m
- An Overview of the Sample Project 1m
- Demo: Unit Testing with GTest 2m
- Summary 1m
- Module Overview 3m
- Google's C++ Test Framework 2m
- Test Names Using GTest 1m
- Running Tests from the Command Line 6m
- Demo: Writing and Running Unit Tests 7m
- The Three Parts of Unit Testing 2m
- Introducing Assertions 3m
- Basic Assertions 3m
- Why Should You Care About Failure Messages? 2m
- String Assertions 1m
- Exception Assertions 2m
- Predicate Assertions 1m
- More Assertions 1m
- Demo: Using Assertions 3m
- Creating Test Fixtures 3m
- Using Parameterized Tests 3m
- C++ Unit Testing Frameworks Comparison 8m
- Summary 1m
- Module Overview 1m
- Unit Tests vs. Integration Tests 4m
- Removing Dependecies 2m
- Demo: Writing Manual Mocks 4m
- Never Write Your Own Fake Objects 2m
- Mocks, Stubs, and Fakes 2m
- Getting Started with GMock 3m
- Demo: Creating Fake Objects with GMock 2m
- Faking Templates and Static Functions 1m
- Using Dependency Injection 3m
- Demo: Using Dependency Injection 2m
- Summary 1m
- Module Overview 2m
- Setting and Checking Behaviors 5m
- Verifying Method Calls 4m
- State Based Testing vs. Interaction Testing 4m
- Naggy, Nice, and Strict Mocks 3m
- Verifying Calls Are Made in the Correct Order 3m
- Controlling Expectations Lifecycle 2m
- Using VerifyAndClear 2m
- Using GMock with Other Testing Frameworks 4m
- Summary 1m
- Module Overview 2m
- Using Simple Matchers 4m
- Why Use Matchers? 2m
- Type Based Matchers 1m
- Using Matchers to Perform Different Actions 2m
- String Matchers 1m
- Demo: Using Matchers 2m
- Combining Matchers and Using Members Matchers 3m
- Assertions and Matchers 1m
- Container Matchers 2m
- Demo: Using Assertions with Container Matchers 4m
- Multi-argument Matchers 1m
- Additional Matchers 1m
- Creating New Matchers 2m
- Demo: Creating New Matchers 3m
- Matchers Best Practices 2m
- Summary 1m
- Module Overview 1m
- Defining Legacy Code 3m
- Handling Legacy Code 2m
- The Legacy Code Dilemma 2m
- Sensing and Separation 2m
- Difficult to Fake Dependencies 2m
- Faking Static and Non-virtual Methods 1m
- Faking Private and Protected Methods 1m
- Using Hi-perf Dependency Injection 5m
- Introduce Instance Delegator 3m
- Faking Singletons 2m
- Extract and Override 4m
- Summary 1m
Course FAQ
Now known as the Googletest Mocking Framework, Google Mock is the standard mocking framework for C++ developers.
gMock is used for creating fake objects in order to remove external dependencies for effective testing.
The latest Google Mock download is found on Google's Open Source site.
This course is for C++ developers but can also be applied to testing in other objective-oriented languages like Java or C#.
This course will teach you how to use Googletest and the Google Mock Framework.