Spock: Up and Running. Writing Expressive Tests in Java and Groovy

- Autor:
- Rob Fletcher
- Promocja Przejdź


- Ocena:
- Bądź pierwszym, który oceni tę książkę
- Stron:
- 372
- Dostępne formaty:
-
ePubMobi
Opis książki: Spock: Up and Running. Writing Expressive Tests in Java and Groovy
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
Wybrane bestsellery
-
Ta książka jest kolejnym, zaktualizowanym i uzupełnionym wydaniem kultowego podręcznika dla profesjonalnych programistów Javy. To pierwszy tom, w którym opisano podstawy języka i najważniejsze zagadnienia związane z programowaniem interfejsu użytkownika, a także kolekcje, wyrażenia lambda, techni...(0,00 zł najniższa cena z 30 dni)
77.40 zł
129.00 zł(-40%) -
Znalezienie odpowiedzi na zaprzątające umysł pytania z zakresu automatyzacji zwykle wiąże się ze spędzeniem długich godzin na wertowaniu niespójnej dokumentacji lub przeszukiwaniu forum Atlassian Community, gdzie swoimi problemami (a także autorskimi pomysłami na ich rozwiązanie) dzielą się inni ...
Atlassian Jira Server & Data Center. Programowanie rozwiązań w projektach biznesowych Atlassian Jira Server & Data Center. Programowanie rozwiązań w projektach biznesowych
(0,00 zł najniższa cena z 30 dni)41.40 zł
69.00 zł(-40%) -
Język Java jest konsekwentnie udoskonalany i unowocześniany dzięki zaangażowaniu wielu ludzi. Nowoczesny język Java staje się coraz bardziej wieloparadygmatowy, co oznacza, że stosowanie najlepszych praktyk w coraz większym stopniu determinuje jakość kodu. Obecnie napisanie kodu, który prawidłowo...(0,00 zł najniższa cena z 30 dni)
59.40 zł
99.00 zł(-40%) -
To dwunaste, rozszerzone wydanie znakomitego podręcznika do nauki Javy, w pełni przejrzane, poprawione i zaktualizowane (uwzględnia nowości wprowadzone w Javie SE 9, 10 i 11). Ułatwia zdobycie solidnych podstaw języka i płynne przejście do tworzenia programów służących do rozwiązywania konkretnyc...
Wprowadzenie do Javy. Programowanie i struktury danych. Wydanie XII Wprowadzenie do Javy. Programowanie i struktury danych. Wydanie XII
(0,00 zł najniższa cena z 30 dni)59.90 zł
199.00 zł(-70%) -
Ta książka jest ósmym wydaniem znakomitego podręcznika programowania dla początkujących, starannie zaktualizowanym i uzupełnionym o informacje dotyczące edycji 11. Zawiera podstawową wiedzę o kompilacji i uruchamianiu programu w Javie oraz o słowach kluczowych i istotnych konstrukcjach w tym języ...(0,00 zł najniższa cena z 30 dni)
59.40 zł
99.00 zł(-40%) -
To kolejne, uzupełnione i zaktualizowane wydanie przewodnika po frameworku Spring. Książka jest napisana w zwięzłym, przejrzystym i jasnym stylu, dzięki czemu szybko zrozumiesz zasady pracy ze Springiem i zbudujesz nowoczesną aplikację internetową współpracującą z bazą danych. Pokazano tu technik...(0,00 zł najniższa cena z 30 dni)
53.40 zł
89.00 zł(-40%) -
Ta książka jest jedenastym wydaniem wyczerpującego kompendium programisty Javy, w pełni zaktualizowanym, uzupełnionym o nowości wprowadzone w Java SE 11. Opisuje język kompleksowo: jego składnię, słowa kluczowe oraz najistotniejsze zasady programowania. Zawiera także informacje o najważniejszych ...(0,00 zł najniższa cena z 30 dni)
119.40 zł
199.00 zł(-40%) -
Oto kolejne, przejrzane, zaktualizowane i uzupełnione wydanie znakomitego podręcznika dla zawodowych programistów Javy. Znalazł się tu dokładny opis sposobów tworzenia interfejsu użytkownika, stosowania rozwiązań korporacyjnych, sieciowych i zabezpieczeń, a także nowości wprowadzonych w JDK 11. P...(0,00 zł najniższa cena z 30 dni)
89.40 zł
149.00 zł(-40%) -
What will you learn from this book?Head First Java is a complete learning experience in Java and object-oriented programming. With this book, you'll learn the Java language with a unique method that goes beyond how-to manuals and helps you become a great programmer. Through puzzles, mysteries, an...(0,00 zł najniższa cena z 30 dni)
237.15 zł
279.00 zł(-15%) -
Algorytm jest pojęciem ściśle związanym z programowaniem. Jak podaje definicja, algorytm to skończony ciąg jasno zdefiniowanych czynności koniecznych do wykonania pewnego rodzaju zadań. W efekcie ich wykonania następuje rozwiązanie postawionego problemu. Brzmi informatycznie? Oczywiście - wszak a...
Algorytmy i struktury danych. Kurs video. Java, JavaScript, Python Algorytmy i struktury danych. Kurs video. Java, JavaScript, Python
(0,00 zł najniższa cena z 30 dni)44.50 zł
89.00 zł(-50%)
Ebooka przeczytasz na:
-
czytnikach Inkbook, Kindle, Pocketbook i innych
-
systemach Windows, MacOS i innych
-
systemach Windows, Android, iOS, HarmonyOS
-
na dowolnych urządzeniach i aplikacjach obsługujących formaty: PDF, EPub, Mobi
Masz pytania? Zajrzyj do zakładki Pomoc »
Audiobooka posłuchasz:
-
w aplikacji Ebookpoint na Android, iOS, HarmonyOs
-
na systemach Windows, MacOS i innych
-
na dowolonych urządzeniach i aplikacjach obsługujących format MP3 (pliki spakowane w ZIP)
Masz pytania? Zajrzyj do zakładki Pomoc »
Kurs Video zobaczysz:
-
w aplikacji Ebookpoint na Android, iOS, HarmonyOs
-
na systemach Windows, MacOS i innych
-
na dowolonych urządzeniach i aplikacjach obsługujących format MP4 (pliki spakowane w ZIP)
Szczegóły książki
- ISBN Ebooka:
- 978-14-919-2324-5, 9781491923245
- Data wydania ebooka:
-
2017-05-08
Data wydania ebooka często jest dniem wprowadzenia tytułu do sprzedaży i może nie być równoznaczna z datą wydania książki papierowej. Dodatkowe informacje możesz znaleźć w darmowym fragmencie. Jeśli masz wątpliwości skontaktuj się z nami sklep@helion.pl.
- Język publikacji:
- angielski
- Rozmiar pliku ePub:
- 2.3MB
- Rozmiar pliku Mobi:
- 6.0MB
- Kategorie:
Programowanie » Java - Programowanie
Spis treści książki
- Introduction
- Meet Spock
- A Short Background on Groovy
- Who Is This Book For?
- About This Book
- Navigating This Book
- Conventions Used in This Book
- Using Code Examples
- OReilly Safari
- How to Contact Us
- Acknowledgments
- I. Spock 101
- 1. The Up and Running Part
- Installation
- Running with the JUnit Runner
- Running with Gradle
- When Groovy Is Used in the Project
- Synchronizing Groovy Versions Between Main and Test Classpaths
- Running with Maven
- 2. Specification Basics
- Anatomy of a Specification
- Why Use Quoted Strings for Feature Method Names?
- Anatomy of a Specification
- An Introduction to Spocks Blocks
- Block Taxonomy
- Basic Block Usage
- The Specification Lifecycle
- Fixture methods: setup and cleanup
- Block Descriptions
- and: blocks
- A Note on Comprehensibility
- Summary
- Comparison with JUnit
- 3. Spock Assertions
- The Importance of Good Diagnostics
- The Power Assert
- Type Information in Power Asserts
- Using Groovy for Effective Assertions
- Using List Comprehensions and List Literals
- Asserting Something About Every Item in a Collection
- Expressive Assertions with Groovy Operators
- Expecting Exceptions
- Interrogating the Exception
- Grouping Assertions on the Same Object
- Summary
- 4. Managing Resources
- How (Not) to Approach Persistence Testing
- Testing a Persistence Layer
- Managing Resources with the Spock Lifecycle
- Specifications and Inheritance
- Execution Order of Lifecycle Methods in an Inheritance Hierarchy
- Summary
- 5. Interaction 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
- Wildcard Shortcuts
- Defining Behavior for Mocked Methods
- Removing Invocation Constraints with Stubs
- When Should I Use a Mock and When Should I Use a Stub?
- Mixing Mocks and Stubs
- Summary
- 6. Parameterized Specifications
- Paramaterization in JUnit
- Spocks where: block
- Separating Iteration Reporting by Using @Unroll
- Adding @Unroll Descriptions
- @Unroll Tokens in Feature Method Names
- Class Level @Unroll Annotations
- Multiple Data Pipes
- Data Tables
- Fields and Methods as Data Providers
- Derived Values
- Clarifying @Unroll Expressions
- Summary
- II. Advanced Spock
- 7. Idiomatic Spock
- Organizing Tests
- The Test-per-Method Antipattern
- Organizing Tests
- Well-Factored Specifications
- Sharing Helper Methods
- Sharing Methods by Using import static
- Sharing Methods with Groovy Traits
- Sharing Methods with Delegation
- Helper Methods and Assertions
- Helper Methods and Mock Interactions
- Comparing Before and After Values
- The Grammar of Blocks
- Separation of Logic and Data with where: Blocks
- Using when/then or given/expect
- Separating Preconditions
- Separating Preconditions from Actions
- Method Parameter Capture with Mocks
- Using a Closure as a Parameter Predicate
- Using Hamcrest for Parameter Predicates
- Parameter Capture Using a Mock Responder
- @Stepwise Specifications
- How to Use @Stepwise
- Disadvantages of @Stepwise
- Conditional Specifications
- Marking Pending Features
- Selectively Executing Tests
- Automatically Cleaning Up Resources
- Documenting Specifications
- Summary
- 8. Advanced where: Blocks
- A Primary Key Verifier
- A Static Site Link Checker
- JBake Configuration
- A Data Pipe Driven by a File
- A Filtered Data Pipe
- Relative Filepaths
- Summary
- 9. Asynchronous Testing
- Blocking Constructs
- BlockingVariable
- BlockingVariables
- Blocking Constructs
- Testing Nonblocking APIs by Using Callbacks
- Using BlockingVariable in a Callback
- Using a Reference to BlockingVariable.set as a Callback
- Awaiting Multiple Values with BlockingVariables
- Improving diagnostics
- Polling for Eventual State
- Using PollingConditions as a Delegate
- Asynchronous Interaction Testing
- Asynchronous Parameter Capture
- Extending BlockingVariable
- Summary
- 10. Extending Spock
- The Message Timeline
- Hamcrest Matchers
- Hamcrest Support in Spock
- JUnit Rules
- Reusable Data Cleanup
- Simplifying the Rule by Using ExternalResource
- Making the Cleanup Logic Generic
- Spock Extensions
- Data Cleanup as a Spock Extension
- Further Steps
- Global Extensions
- Taking it Further
- Summary
- 11. Test-Driven Development: The Diamond Kata
- The Diamond Kata
- Implementation
- First Step: The Pathological Case
- The Simplest Valid Diamond
- Enforcing Invariants
- Matrix Content
- Symmetry
- Eliminating the Assertion Loop
- Adding Padding to the Rows
- Refinement
- Summary
- III. Integrating Spock
- 12. Spock and Spring
- What Do We Mean by Integration Tests?
- Container Tests
- What Do We Mean by Integration Tests?
- Spring Compatibility
- @SpringBootTest
- Testing Annotation-Driven Transactions
- Tracking Who Is Mentioned in a Message
- Non-Spring-Dependent Tests
- Testing a Transaction Rollback
- Setting Up the Spring Application
- A First Integration Test
- Convenience and Cost
- Unexpected Side Effects
- Forcing Spring to Re-Create the Application Context
- A Better Way to Force Errors
- Mock and Stub Beans
- Mention Events
- Mock Beans Before Spock 1.1
- Mock Bean Delegates
- Detached Mocks in the Spring Context
- Spring Autoconfiguration and Test Configuration Classes
- Mock Beans in XML Configuration
- Replacing Application Beans with Mocks
- Declarative Test Data
- Using the @Sql Annotation for Data Fixtures
- Global Fixture Data
- Cleaning Up Test Data Spring-Style
- Tests in Transactions
- Propagated Transactions
- Summary
- 13. Testing REST APIs
- Defining the Application URL
- A First Specification
- Web Application Lifecycle
- Creating Data for End-to-End Tests
- Bleeding Data Between Tests
- Creating Test Data on Demand
- Cleaning Up Test Data
- Requests with Data
- Fixture Methods
- Testing for HTTP Errors
- Verifying Response Data
- Typed Response Entities
- Multiple HTTP Requests in a Feature Method
- Backdoors or Pure API Testing?
- Handling Redirect Responses
- Verifying Redirect Details
- REST API Security
- Authentication versus Authorization
- Summary
- 14. End-to-End Web Testing
- Geb
- Getting Started with Geb
- A First Frontend Test
- Introducing Page Models
- Setting the Base URL
- Gebs Automatic Delegation
- Authentication
- Encapsulating Interactions by Using Methods
- Modules
- Parameterized Pages
- Interacting with Forms
- Accessing Form Elements by Name
- Encapsulating Interactions with Methods
- Form Validation
- 15. Testing JavaScript Using Spock
- Why Test JavaScript from the JVM?
- Setting Up Nashorn for Tests
- Calling JavaScript Functions
- JavaScript Functions as Objects
- Specifying this in a JavaScript Function
- Testing an Isomorphic View Component
- An Invocable Script Engine as a Delegate
- Passing Mocks to JavaScript
- Rendering a View with the Handlebars Library
- Compiling Handlebars Templates
- Testing Template Rendering
- Handling Properties That Dont Convert to JavaScript
- Registering Handlebars Helper Functions
- Composing Templates with Handlebars Partials
- Passing Iterable Values to JavaScript
- Summary
- 16. Test Driving an RxJava Application
- Tests, Behaviors, and Properties
- The Skeleton Implementation
- Test Driving the Implementation
- Defining the Behavior
- A First Test
- Polling at Regular Intervals
- No Sleep `Til the Test Goes Green
- Testing Subscription to the Stream
- Unchunking the Message Stream
- Requesting Messages Since the Last Received
- Recovering from Polling Errors
- Recovering from Downstream Errors
- Final Implementation
- A. Groovy Primer
- History
- Syntactic and Semantic Differences to Java
- Semicolons
- Import Statements
- Class Literals
- Visibility
- Exceptions
- Implicit Return
- Default Parameters
- Method Dispatch
- Valid Java Code That Is Not Valid Groovy Code
- Array initialization
- Multiple for loop variables or increments
- The dowhile loop
- Try with resource (Java 7+)
- Lambdas (Java 8+)
- Method references (Java 8+)
- Dynamic-Typed Variables
- List and Map literals
- Lists
- Indexing lists
- Lists
- Maps
- Programmatically assigning map keys
- Accessing map values
- Ranges
- Immutability
- Maps as Named Arguments
- Set and Array Literals
- Truthiness
- Properties
- Accessing Properties
- Properties of Java Classes
- Strings in Groovy
- Templated Strings
- Regular Expression Literals
- The Dollar-Slashy String
- Multiline Strings
- Operator Overloading
- Unary Math Operators
- Comparison Operators
- Mathematical Operators
- Bitwise Operators
- Shift Operators
- Operators Not Present in Java
- Safe Dereference Operator
- Call Operator
- Subscript Operators
- Elvis Operator
- Spaceship Operator
- Spread Operators
- Spreading parameters
- Regular Expression Operators
- Field Access Operator
- Method Pointer Operator
- Operator-Like Keywords
- Closures
- Defining Closures
- Optional parameter types
- The implicit closure parameter
- Defining Closures
- Methods That Accept Closures
- Closure Delegates
- Parameter and Delegate Type Information
- Closures and Java 8 Functional Interfaces
- The Groovy Development Kit
- Functional Iterator Methods
- each(Closure)
- eachWithIndex(Closure)
- find(Closure)
- findAll(Closure)
- collect(Closure)
- any(Closure)
- every(Closure)
- Functional Iterator Methods
- Chained Functional Style
- AST Transformations
- Summary
- Bibliography
- Index
O'Reilly Media - inne książki
-
FinOps brings financial accountability to the variable spend model of cloud. Used by the majority of global enterprises, this management practice has grown from a fringe activity to the de facto discipline managing cloud spend. In this book, authors J.R. Storment and Mike Fuller outline the proce...(0,00 zł najniższa cena z 30 dni)
262.65 zł
309.00 zł(-15%) -
Edge AI is transforming the way computers interact with the real world, allowing IoT devices to make decisions using the 99% of sensor data that was previously discarded due to cost, bandwidth, or power limitations. With techniques like embedded machine learning, developers can capture human intu...(0,00 zł najniższa cena z 30 dni)
262.65 zł
309.00 zł(-15%) -
Why is it difficult for so many companies to get digital identity right? If you're still wrestling with even simple identity problems like modern website authentication, this practical book has the answers you need. Author Phil Windley provides conceptual frameworks to help you make sense of all ...(0,00 zł najniższa cena z 30 dni)
186.15 zł
219.00 zł(-15%) -
Python was recently ranked as today's most popular programming language on the TIOBE index, thanks to its broad applicability to design and prototyping to testing, deployment, and maintenance. With this updated fourth edition, you'll learn how to get the most out of Python, whether you're a profe...(0,00 zł najniższa cena z 30 dni)
305.15 zł
359.00 zł(-15%) -
With the accelerating speed of business and the increasing dependence on technology, companies today are significantly changing the way they build in-house business solutions. Many now use low-code and no code technologies to help them deal with specific issues, but that's just the beginning. Wit...
Building Solutions with the Microsoft Power Platform Building Solutions with the Microsoft Power Platform
(0,00 zł najniższa cena z 30 dni)262.65 zł
309.00 zł(-15%) -
Companies are scrambling to integrate AI into their systems and operations. But to build truly successful solutions, you need a firm grasp of the underlying mathematics. This accessible guide walks you through the math necessary to thrive in the AI field such as focusing on real-world application...(0,00 zł najniższa cena z 30 dni)
262.65 zł
309.00 zł(-15%) -
DevOps engineers, developers, and security engineers have ever-changing roles to play in today's cloud native world. In order to build secure and resilient applications, you have to be equipped with security knowledge. Enter security as code.In this book, authors BK Sarthak Das and Virginia Chu d...(0,00 zł najniższa cena z 30 dni)
186.15 zł
219.00 zł(-15%) -
With the increasing use of AI in high-stakes domains such as medicine, law, and defense, organizations spend a lot of time and money to make ML models trustworthy. Many books on the subject offer deep dives into theories and concepts. This guide provides a practical starting point to help develop...(0,00 zł najniższa cena z 30 dni)
262.65 zł
309.00 zł(-15%) -
Why are so many companies adopting GitOps for their DevOps and cloud native strategy? This reliable framework is quickly becoming the standard method for deploying apps to Kubernetes. With this practical, developer-oriented book, DevOps engineers, developers, IT architects, and SREs will learn th...(0,00 zł najniższa cena z 30 dni)
262.65 zł
309.00 zł(-15%) -
Learn the essentials of working with Flutter and Dart to build full stack applications that meet the needs of a cloud-driven world. Together, the Flutter open source UI software development kit and the Dart programming language for client development provide a unified solution to building applica...(0,00 zł najniższa cena z 30 dni)
220.15 zł
259.00 zł(-15%)
Dzieki opcji "Druk na żądanie" do sprzedaży wracają tytuły Grupy Helion, które cieszyły sie dużym zainteresowaniem, a których nakład został wyprzedany.
Dla naszych Czytelników wydrukowaliśmy dodatkową pulę egzemplarzy w technice druku cyfrowego.
Co powinieneś wiedzieć o usłudze "Druk na żądanie":
- usługa obejmuje tylko widoczną poniżej listę tytułów, którą na bieżąco aktualizujemy;
- cena książki może być wyższa od początkowej ceny detalicznej, co jest spowodowane kosztami druku cyfrowego (wyższymi niż koszty tradycyjnego druku offsetowego). Obowiązująca cena jest zawsze podawana na stronie WWW książki;
- zawartość książki wraz z dodatkami (płyta CD, DVD) odpowiada jej pierwotnemu wydaniu i jest w pełni komplementarna;
- usługa nie obejmuje książek w kolorze.
W przypadku usługi "Druk na żądanie" termin dostarczenia przesyłki może obejmować także czas potrzebny na dodruk (do 10 dni roboczych)
Masz pytanie o konkretny tytuł? Napisz do nas: sklep[at]helion.pl.
Książka, którą chcesz zamówić pochodzi z końcówki nakładu. Oznacza to, że mogą się pojawić drobne defekty (otarcia, rysy, zagięcia).
Co powinieneś wiedzieć o usłudze "Końcówka nakładu":
- usługa obejmuje tylko książki oznaczone tagiem "Końcówka nakładu";
- wady o których mowa powyżej nie podlegają reklamacji;
Masz pytanie o konkretny tytuł? Napisz do nas: sklep[at]helion.pl.


Oceny i opinie klientów: Spock: Up and Running. Writing Expressive Tests in Java and Groovy Rob Fletcher (0)
Weryfikacja opinii następuję na podstawie historii zamówień na koncie Użytkownika umieszczającego opinię. Użytkownik mógł otrzymać punkty za opublikowanie opinii uprawniające do uzyskania rabatu w ramach Programu Punktowego.