Learn about the Go testing fundamentals and techniques to leverage Test-Driven Development, (TDD) for delivering and maintaining microservice architectures, including unit testing, end-to-end testing, and contract testing.
Key Features
- Write Go test suites using popular mocking and assertion frameworks
- Leverage TDD to implement end-to-end testing of HTTP web applications and microservice architectures
- Master testing and debugging techniques for suites that cover edge cases and concurrent code
Book Description
Experienced developers know that designing a comprehensive testing strategy is vital to shipping and maintaining services in production. This book teaches you to leverage TDD, which is already an industry practice, for testing your Go applications at different levels. In addition, one chapter discusses the challenges and approaches of testing concurrent code, which requires different techniques for testing and profiling.
You'll use TDD to solve and test a variety of problems, from simple mathematical functions to web applications. You'll learn how to structure and run your unit tests, and what assertion frameworks are available for you to use. You'll implement test suites using table-driven testing, which is a common technique used in Go. Then, you'll write and run Behavior-Driven Development (BDD) style tests. You'll learn more complex topics that require end-to-end testing with mocking and contract testing via practical examples. Finally, you'll explore the difficult aspects of implementing and running TDD in production. You'll come across the challenges of testing concurrent code and fuzzing.
By the end of this book, you'll design and implement a comprehensive testing strategy for your Go applications and microservice architectures.
What you will learn
- Understand the benefits and techniques of TDD
- Create practical Go unit tests using mocks and assertions
- Build table-driven test suites for HTTP web applications
- Use Cucumber to reliably test web applications end-to-end
- Verify microservice architectures using contract testing
- Write and test Go concurrency mechanisms efficiently
- Develop useful tests that cover edge cases using property testing and fuzzing
- Learn effective debugging strategies for non-deterministic test failures
Who This Book Is For
If you are an intermediate-level developer or software testing professional who knows Go fundamentals and is looking to deliver projects with Go, then this book is for you. Knowledge of Go syntax, structs, functions, and interfaces will help you get the most out of this book.
Table of Contents
- Getting to Grips with Test-Driven Development
- Unit Testing Essentials
- Mocking and assertion frameworks
- Building efficient test suites
- Performing End-to-end testing
- Testing the book swap web application
- Refactoring in Go
- Testing microservice architectures
- Challenges of testing concurrent code
- Testing edge cases
- Working with Generic test utilities
- Debugging intermittent test failures