From the course: Test-Driven Development in C++

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Google Mock example

Google Mock example

- [Instructor] Now I'm going to go over a very simple working example. In this example, I'm going to use TDD with Google Test and Google Mock to implement a class that holds data. First I'm going to create an interface class for a queue that can enqueue and dequeue data. Then I'm going to create a mock class for that interface. With all of that in place, I'll use TDD to implement a DataHolder class that will be passed in an instance of the queue interface, and its constructor, and will implement the getData and addData methods that will use the queue's enqueue and dequeue methods. I've created a new C++ project for this kata, and verified that it builds and executes. My next step it to get it configured to use Google Test and Google Mock. To do that, I need to add their include path, libraries, and library paths for Google Test and Google Mock to the project. Okay, so I'll right-click on my GMockTest project, which is the project I created for this kata, and then under C/C++ General…

Contents