Instant Mockito
Marcin Grzejszczak
- 出版商: Packt Publishing
- 出版日期: 2013-08-16
- 售價: $1,100
- 貴賓價: 9.5 折 $1,045
- 語言: 英文
- 頁數: 66
- 裝訂: Paperback
- ISBN: 1782167978
- ISBN-13: 9781782167976
海外代購書籍(需單獨結帳)
買這商品的人也買了...
-
$880$695 -
$580$458 -
$940$700 -
$1,240$1,178 -
$454Jenkins 權威指南
-
$580$493 -
$332遊戲情感設計:如何觸動玩家的心靈
-
$580$452 -
$480$379 -
$653Jenkins 2 權威指南 (Jenkins 2: Up and Running: Evolve Your Deployment Pipeline for Next Generation Automation)
-
$520$411 -
$403OpenShift 助力 DevOps : 雲部署更簡單 (DevOps with OpenShift: Cloud Deployments Made Easy)
-
$480$336 -
$709OpenShift 在企業中的實踐:PaaS DevOps 微服務
相關主題
商品描述
Learn how to create stubs, mocks, and spies and verify their behavior using Mockito
Overview
- Learn something new in an Instant! A short, fast, focused guide delivering immediate results
- Stub methods with callbacks
- Verify the behavior of test mocks
- Assert the arguments passed to functions of mocks
- Create custom argument matchers
In Detail
Mockito is an open source testing framework for Java that automates unit tests for use in test-driven development (TDD) or behavior-driven development (BDD), decoupling test code from the system under test by eliminating the expect-run-verify pattern. It lets you write beautiful tests with a clean and simple API.
Instant Mockito contains plenty of real-life examples on how to unit test your code. It shows you how to use this testing framework and explains best practices on how to use it effectively.
Instant Mockito helps you break each significant method into a set of practical examples. It will clarify all the concepts of unit testing and Mockito.
You will learn how to properly capture and verify arguments passed into your stubbed methods. We will also take a look at verifying an order and returning custom answers on the stubs. If you want to take advantage of using the Mockito framework’s API to tame your code base, then this is the book for you.
You will learn everything you need to know to unit test your code in a clear, readable, and high quality manner.
What you will learn from this book
- Create stubs, mocks, and spies
- Perform argument matching
- Work with void methods and thrown exceptions
- Perform stubbing with a custom answer
- Verify the behaviour of mocks
- Perform argument capturing
- Verify the call order
- Work with asynchronous code
- Learn about partial mocking
- Reduce boilerplate code with annotations
- Learn about advanced mock configuration
Approach
Filled with practical, step-by-step instructions and clear explanations for the most important and useful tasks. This is a standard, tutorial-based guide using plenty of examples for illustration.
Who this book is written for
Instant Mockito is ideal for developers new to unit testing, who are looking to get to know how to create high quality tests using Mockito. It’s assumed that you will have some experience in Java already.
商品描述(中文翻譯)
學習如何使用 Mockito 創建存根、模擬和間諜,並驗證它們的行為
概述
- 立即學習新知!一本短小、快速、專注的指南,提供即時結果
- 使用回調創建存根方法
- 驗證測試模擬的行為
- 斷言傳遞給模擬函數的參數
- 創建自定義參數匹配器
詳細內容
Mockito 是一個開源的 Java 測試框架,旨在自動化單元測試,以用於測試驅動開發(TDD)或行為驅動開發(BDD),通過消除期望-執行-驗證模式來解耦測試代碼與被測系統。它讓你能夠使用乾淨且簡單的 API 編寫優雅的測試。
Instant Mockito 包含大量現實生活中的範例,展示如何對你的代碼進行單元測試。它告訴你如何使用這個測試框架,並解釋如何有效使用的最佳實踐。
Instant Mockito 幫助你將每個重要的方法拆分為一組實用的範例。它將澄清單元測試和 Mockito 的所有概念。
你將學會如何正確捕獲和驗證傳遞到你的存根方法中的參數。我們還將查看如何驗證調用順序並在存根上返回自定義答案。如果你想利用 Mockito 框架的 API 來管理你的代碼庫,那麼這本書就是為你而寫的。
你將學到所有需要知道的知識,以清晰、可讀且高品質的方式對你的代碼進行單元測試。
你將從這本書中學到的內容
- 創建存根、模擬和間諜
- 執行參數匹配
- 處理 void 方法和拋出的異常
- 使用自定義答案進行存根
- 驗證模擬的行為
- 執行參數捕獲
- 驗證調用順序
- 處理異步代碼
- 了解部分模擬
- 使用註解減少樣板代碼
- 了解高級模擬配置
方法
本書充滿了實用的逐步指導和對最重要、最有用任務的清晰解釋。這是一本標準的基於教程的指南,使用大量範例進行說明。
本書的讀者對象
Instant Mockito 非常適合對單元測試不熟悉的開發者,幫助他們了解如何使用 Mockito 創建高品質的測試。假設你已經具備一定的 Java 經驗。