Test-Driven Development in Go: A practical guide to writing idiomatic and efficient Go tests through real-world examples

Simion, Adelina

  • 出版商: Packt Publishing
  • 出版日期: 2023-04-28
  • 售價: $1,590
  • 貴賓價: 9.5$1,511
  • 語言: 英文
  • 頁數: 338
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 1803247878
  • ISBN-13: 9781803247878
  • 相關分類: Go 程式語言TDD 測試導向開發
  • 海外代購書籍(需單獨結帳)

買這商品的人也買了...

商品描述

Explore Go testing techniques and leverage TDD to deliver and maintain microservices architecture, including contract, end-to-end, and unit testing

Purchase of the print or Kindle book includes a free PDF eBook


Key Features:

  • Write Go test suites using popular mocking and testing frameworks
  • Leverage TDD to implement testing at all levels of web applications and microservices architecture
  • Master the art of writing tests that cover edge cases and concurrent code



Book Description:

Experienced developers understand the importance of designing a comprehensive testing strategy to ensure efficient shipping and maintaining services in production. This book shows you how to utilize test-driven development (TDD), a widely adopted industry practice, for testing your Go apps at different levels. You'll also explore challenges faced in testing concurrent code, and learn how to leverage generics and write fuzz tests.

The book begins by teaching you how to use TDD to tackle various problems, from simple mathematical functions to web apps. You'll then learn how to structure and run your unit tests using Go's standard testing library, and explore two popular testing frameworks, Testify and Ginkgo. You'll also implement test suites using table-driven testing, a popular Go technique. As you advance, you'll write and run behavior-driven development (BDD) tests using Ginkgo and Godog. Finally, you'll explore the tricky aspects of implementing and testing TDD in production, such as refactoring your code and testing microservices architecture with contract testing implemented with Pact. All these techniques will be demonstrated using an example REST API, as well as smaller bespoke code examples.

By the end of this book, you'll have learned how to design and implement a comprehensive testing strategy for your Go applications and microservices architecture.


What You Will Learn:

  • Create practical Go unit tests using mocks and assertions with Testify
  • Build table-driven test suites for HTTP web applications
  • Write BDD-style tests using the Ginkgo testing framework
  • Use the Godog testing framework to reliably test web applications
  • Verify microservices architecture using Pact contract testing
  • Develop tests that cover edge cases using property testing and fuzzing


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.

商品描述(中文翻譯)

探索Go測試技術,並利用TDD來交付和維護微服務架構,包括合約、端對端和單元測試。

購買印刷版或Kindle書籍將包含免費的PDF電子書。

主要特點:
- 使用流行的模擬和測試框架編寫Go測試套件
- 利用TDD在Web應用程序和微服務架構的所有層次上實施測試
- 掌握編寫涵蓋邊界情況和並發代碼的測試的技巧

書籍描述:
有經驗的開發人員了解設計全面的測試策略以確保高效交付和維護生產服務的重要性。本書將向您展示如何在不同層次上使用廣泛採用的行業實踐——測試驅動開發(TDD)來測試Go應用程序。您還將探索在測試並發代碼時面臨的挑戰,並學習如何利用泛型和編寫模糊測試。

本書首先教您如何使用TDD解決各種問題,從簡單的數學函數到Web應用程序。然後,您將學習如何使用Go的標準測試庫結構和運行單元測試,並探索兩個流行的測試框架Testify和Ginkgo。您還將使用表驅動測試這一流行的Go技術來實現測試套件。隨著進一步的學習,您將使用Ginkgo和Godog編寫和運行行為驅動開發(BDD)測試。最後,您將探索在生產環境中實施和測試TDD的棘手方面,例如重構代碼以及使用Pact實施合約測試來測試微服務架構。所有這些技術都將使用一個示例REST API以及更小的定制代碼示例來演示。

通過閱讀本書,您將學習如何為Go應用程序和微服務架構設計和實施全面的測試策略。

您將學到什麼:
- 使用Testify的模擬和斷言創建實用的Go單元測試
- 為HTTP Web應用程序構建表驅動的測試套件
- 使用Ginkgo測試框架編寫BDD風格的測試
- 使用Godog測試框架可靠地測試Web應用程序
- 使用Pact合約測試驗證微服務架構
- 使用屬性測試和模糊測試開發涵蓋邊界情況的測試

本書適合對Go基礎知識有一定了解並希望使用Go交付項目的中級開發人員或軟件測試專業人士。熟悉Go語法、結構、函數和接口將有助於您充分利用本書的內容。