Scala Test-Driven Development

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

Scala Test-Driven Development

Gaurav Sood

1 customer reviews
Build robust Scala applications by implementing the fundamentals of test-driven development in your workflow
Mapt Subscription
FREE
€29.73/m after trial
eBook
€23.32
RRP €33.30
Save 29%
Print + eBook
€34.99
RRP €34.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
€0.00
€23.32
€34.99
€29.74 p/m after trial
RRP €33.30
RRP €34.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Scala Test-Driven Development Book Cover
Scala Test-Driven Development
€ 33.30
€ 23.32
Learning Concurrent Programming in Scala - Second Edition Book Cover
Learning Concurrent Programming in Scala - Second Edition
€ 41.63
€ 29.15
Buy 2 for €35.42
Save €33.20
Add to Cart

Book Details

ISBN 139781786464675
Paperback198 pages

Book Description

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.

Table of Contents

Chapter 1: Hello, TDD!
What is TDD?
Why TDD?
Changing our approach to problem solving
Brief introduction to Scala and SBT
Hello World!
Summary
Chapter 2: First Test-Driven Application
Testing frameworks
ScalaTest
Problem statements
IDE
Project structure
Write a failing test – RED
Writing application code to fix the test – GREEN
More tests – REPEAT
Intercepting exceptions
Summary
Chapter 3: Clean Code Using ScalaTest
Assertions
Matchers
Some more Matchers
Base test classes
Test fixtures
Problem statement
Summary
Chapter 4: Refactor Mercilessly
Clean code
Red-Green-Refactor
Code smell
To refactor or not to refactor
Refactoring techniques
Summary
Chapter 5: Another Level of Testing
Integration testing
Behavior-driven development
Talk is cheap
Summary
Chapter 6: Mock Objects and Stubs
History
Coupling
Stubs
Mock objects
Fakes
Spy
Mocking frameworks
Mockito
ScalaMock
Summary
Chapter 7: Property-Based Testing
Introduction to property-based testing
Generator-driven properties
ScalaCheck
Summary
Chapter 8: Scala TDD with Specs2
Introduction to Specs2
Differences between Specs2 and ScalaTest
Setting up Specs2
Styles
Acceptance specification
Matchers
Specs2 data tables
Running Specs2 tests
Summary
Chapter 9: Miscellaneous and Emerging Trends in Scala TDD
Scala Futures and Promises
The Inside trait
The OptionValue trait
The EitherValue trait
Eventually
Consumer-Driven Contracts
Summary

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

Authors

Table of Contents

Chapter 1: Hello, TDD!
What is TDD?
Why TDD?
Changing our approach to problem solving
Brief introduction to Scala and SBT
Hello World!
Summary
Chapter 2: First Test-Driven Application
Testing frameworks
ScalaTest
Problem statements
IDE
Project structure
Write a failing test – RED
Writing application code to fix the test – GREEN
More tests – REPEAT
Intercepting exceptions
Summary
Chapter 3: Clean Code Using ScalaTest
Assertions
Matchers
Some more Matchers
Base test classes
Test fixtures
Problem statement
Summary
Chapter 4: Refactor Mercilessly
Clean code
Red-Green-Refactor
Code smell
To refactor or not to refactor
Refactoring techniques
Summary
Chapter 5: Another Level of Testing
Integration testing
Behavior-driven development
Talk is cheap
Summary
Chapter 6: Mock Objects and Stubs
History
Coupling
Stubs
Mock objects
Fakes
Spy
Mocking frameworks
Mockito
ScalaMock
Summary
Chapter 7: Property-Based Testing
Introduction to property-based testing
Generator-driven properties
ScalaCheck
Summary
Chapter 8: Scala TDD with Specs2
Introduction to Specs2
Differences between Specs2 and ScalaTest
Setting up Specs2
Styles
Acceptance specification
Matchers
Specs2 data tables
Running Specs2 tests
Summary
Chapter 9: Miscellaneous and Emerging Trends in Scala TDD
Scala Futures and Promises
The Inside trait
The OptionValue trait
The EitherValue trait
Eventually
Consumer-Driven Contracts
Summary

Book Details

ISBN 139781786464675
Paperback198 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Learning Concurrent Programming in Scala - Second Edition Book Cover
Learning Concurrent Programming in Scala - Second Edition
€ 41.63
€ 29.15
Scala Microservices Book Cover
Scala Microservices
€ 41.63
€ 29.15
Mastering Akka Book Cover
Mastering Akka
€ 41.63
€ 29.15
Scala High Performance Programming Book Cover
Scala High Performance Programming
€ 39.25
€ 27.48
Scala: Guide for Data Science Professionals Book Cover
Scala: Guide for Data Science Professionals
€ 82.09
€ 57.47
Spring Microservices Book Cover
Spring Microservices
€ 41.63
€ 29.15