Librería Portfolio Librería Portfolio

Búsqueda avanzada

TIENE EN SU CESTA DE LA COMPRA

0 productos

en total 0,00 €

SPOCK: UP AND RUNNING. WRITING EXPRESSIVE TESTS IN JAVA AND GROOVY
Título:
SPOCK: UP AND RUNNING. WRITING EXPRESSIVE TESTS IN JAVA AND GROOVY
Subtítulo:
Autor:
FLETCHER, R
Editorial:
O´REILLY
Año de edición:
2017
Materia
JAVA
ISBN:
978-1-4919-2329-0
Páginas:
372
57,50 €

 

Sinopsis

Most developers would agree that writing automated tests is a good idea, but writing good, well-structured tests is still an elusive skill for many. For Java and Groovy developers, however, there's good news. This practical guide shows you how to write concise and highly readable tests with Spock, the most innovative testing and specification framework for the JVM since JUnit.

Author Rob Fletcher takes you from Spock basics to advanced topics, using fully worked integration examples. Through the course of this book, you'll build a simple web application-Squawker-that allows users to post short messages. You'll discover how much easier it is to write automated tests with Spock's straightforward and expressive language.

Start by learning how to write simple unit tests
Understand the lifecycle of Spock specifications and feature methods
Dive into interaction testing, using Spock's intuitive syntax for dealing with mocks and stubs
Learn about parameterized tests-writing feature methods that run for multiple sets of data
Move into advanced topics, such as writing idiomatic Spock code and driving parameterized tests with file or database input
Learn how everything works together in a standalone, fully-worked, test-driven development example



Spock 101
Chapter 1The "Up and Runningö Part
Installation
Running with the JUnit Runner
Running with Gradle
Running with Maven
Chapter 2Specification Basics
Anatomy of a Specification
An Introduction to Spock's Blocks
The Specification Lifecycle
Block Descriptions
Summary
Chapter 3Spock Assertions
The Importance of Good Diagnostics
The Power Assert
Using Groovy for Effective Assertions
Expecting Exceptions
Grouping Assertions on the Same Object
Summary
Chapter 4Managing Resources
How (Not) to Approach Persistence Testing
Testing a Persistence Layer
Specifications and Inheritance
Summary
Chapter 5Interaction Testing
Asserting that a Method Is Called
Specifying Invocation Cardinality
Declaring the Return Value from a Mocked Method
Parameter Predicates
Disallowing Unexpected Calls or "Strict Mockingö
Looser Matching with Wildcard Parameters
Defining Behavior for Mocked Methods
Removing Invocation Constraints with Stubs
Summary
Chapter 6Parameterized Specifications
Paramaterization in JUnit
Spock's where: block
Separating Iteration Reporting by Using @Unroll
Multiple Data Pipes
Data Tables
Fields and Methods as Data Providers
Derived Values
Summary
Advanced Spock
Chapter 7Idiomatic Spock
Organizing Tests
Well-Factored Specifications
The Grammar of Blocks
Method Parameter Capture with Mocks
@Stepwise Specifications
Conditional Specifications
Automatically Cleaning Up Resources
Documenting Specifications
Summary
Chapter 8Advanced where: Blocks
A Primary Key Verifier
A Static Site Link Checker
Summary
Chapter 9Asynchronous Testing
Blocking Constructs
Testing Nonblocking APIs by Using Callbacks
Polling for Eventual State
Asynchronous Interaction Testing
Summary
Chapter 10Extending Spock
The Message Timeline
Hamcrest Matchers
JUnit Rules
Spock Extensions
Global Extensions
Summary
Chapter 11Test-Driven Development: The Diamond Kata
The Diamond Kata
Implementation
Summary
Integrating Spock
Chapter 12Spock and Spring
What Do We Mean by "Integration Testsö?
Spring Compatibility
Testing Annotation-Driven Transactions
Mock and Stub Beans
Declarative Test Data
Tests in Transactions
Summary
Chapter 13Testing REST APIs
Defining the Application URL
A First Specification
Web Application Lifecycle
Creating Data for End-to-End Tests
Requests with Data
Testing for HTTP Errors
Verifying Response Data
Multiple HTTP Requests in a Feature Method
Backdoors or "Pureö API Testing?
Handling Redirect Responses
REST API Security
Summary
Chapter 14End-to-End Web Testing
Geb
Getting Started with Geb
A First Frontend Test
Introducing Page Models
Authentication
Modules
Parameterized Pages
Interacting with Forms
Form Validation
Chapter 15Testing JavaScript Using Spock
Why Test JavaScript from the JVM?
Setting Up Nashorn for Tests
Calling JavaScript Functions
Testing an Isomorphic View Component
Passing Mocks to JavaScript
Rendering a View with the Handlebars Library
Summary
Chapter 16Test Driving an RxJava Application
Tests, Behaviors, and Properties
The Skeleton Implementation
Test Driving the Implementation
Polling at Regular Intervals
Final Implementation
Appendix Groovy Primer
History
Syntactic and Semantic Differences to Java
Dynamic-Typed Variables
List and Map literals
Truthiness
Properties
Strings in Groovy
Operator Overloading
Operators Not Present in Java
Operator-Like Keywords
Closures
The Groovy Development Kit
AST Transformations
Summary