Scala Test-Driven Development

Gaurav Sood

  • 出版商: Packt Publishing
  • 出版日期: 2016-10-28
  • 售價: $1,760
  • 貴賓價: 9.5$1,672
  • 語言: 英文
  • 頁數: 266
  • 裝訂: Paperback
  • ISBN: 1786464675
  • ISBN-13: 9781786464675
  • 相關分類: JVM 語言TDD 測試導向開發
  • 海外代購書籍(需單獨結帳)
    無現貨庫存(No stock available)


Build robust Scala applications by implementing the fundamentals of test-driven development in your workflow

About This Book

  • Get a deep understanding of various testing concepts such as test-driven development (TDD) and BDD
  • Efficient usage of the built-in Scala features such as ScalaTest, specs2, and Scala check
  • Change your approach towards problem solving by thinking about the boundaries of the problem and its definition rather than focusing on the solution

Who This Book Is For

This book is for Scala developers who are looking to write better quality and easily maintainable code. No previous knowledge of TDD/BDD is required.

What You Will Learn

  • Understand the basics of TDD and its significance
  • Refactoring tests to build APIs in order to increase test coverage
  • How to leverage the inbuilt Scala testing modules like ScalaTest, specs2 and Scala Check
  • Writing test fixtures and apply the concepts of BDD
  • How to divide tests to run at different points in continuous delivery cycle
  • Benefits of refactoring and how it affects the final quality of code produced
  • Understanding of SBT based build environment and how to use it to run tests
  • The fundamentals of mocking and stubbing in Scala and how to use it efficiently

In Detail

Test-driven development (TDD) produces high-quality applications in less time than is possible with traditional methods. Due to the systematic nature of TDD, the application is tested in individual units as well as cumulatively, right from the design stage, to ensure optimum performance and reduced debugging costs.

This step-by-step guide shows you how to use the principles of TDD and built-in Scala testing modules to write clean and fully tested Scala code and give your workflow the change it needs to let you create better applications than ever before.

After an introduction to TDD, you will learn the basics of ScalaTest, one of the most flexible and most popular testing tools around for Scala, by building your first fully test-driven application. Building on from that you will learn about the ScalaTest API and how to refactor code to produce high-quality applications.

We'll teach you the concepts of BDD (Behavior-driven development) and you'll see how to add functional tests to the existing suite of tests. You'll be introduced to the concepts of Mocks and Stubs and will learn to increase test coverage using properties.

With a concluding chapter on miscellaneous tools, this book will enable you to write better quality code that is easily maintainable and watch your apps change for the better.

Style and approach

This step-by-step guide explains the significance of TDD in Scala through various practical examples. You will learn to write a complete test-driven application throughout the course of the book.



- 深入了解各種測試概念,如測試驅動開發(TDD)和行為驅動開發(BDD)。
- 高效使用內建的Scala功能,如ScalaTest、specs2和Scala Check。
- 改變解決問題的方式,專注於問題的邊界和定義,而非解決方案。


- 瞭解TDD的基礎知識及其重要性。
- 重構測試以建立API,以增加測試覆蓋率。
- 如何利用內建的Scala測試模組,如ScalaTest、specs2和Scala Check。
- 撰寫測試固定裝置並應用BDD的概念。
- 如何將測試分割為在持續交付週期的不同點運行。
- 重構的好處以及它如何影響所產生的程式碼的最終品質。
- 瞭解基於SBT的建置環境以及如何使用它來運行測試。
- Scala中模擬和存根的基本原則以及如何有效使用它們。



在介紹TDD之後,您將通過構建第一個完全測試驅動的應用程式來學習ScalaTest的基礎知識,ScalaTest是Scala中最靈活且最受歡迎的測試工具之一。在此基礎上,您將了解ScalaTest API並重構程式碼以產生高品質的應用程式。