• Complain

Rob Fletcher - Spock: Up and Running: Writing Expressive Tests in Java and Groovy

Here you can read online Rob Fletcher - Spock: Up and Running: Writing Expressive Tests in Java and Groovy full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2017, publisher: OReilly Media, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Rob Fletcher Spock: Up and Running: Writing Expressive Tests in Java and Groovy
  • Book:
    Spock: Up and Running: Writing Expressive Tests in Java and Groovy
  • Author:
  • Publisher:
    OReilly Media
  • Genre:
  • Year:
    2017
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Spock: Up and Running: Writing Expressive Tests in Java and Groovy: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Spock: Up and Running: Writing Expressive Tests in Java and Groovy" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

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, theres 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, youll build a simple web applicationSquawkerthat allows users to post short messages. Youll discover how much easier it is to write automated tests with Spocks 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 Spocks intuitive syntax for dealing with mocks and stubs
  • Learn about parameterized testswriting 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
  • Rob Fletcher: author's other books


    Who wrote Spock: Up and Running: Writing Expressive Tests in Java and Groovy? Find out the surname, the name of the author of the book and a list of all author's works by series.

    Spock: Up and Running: Writing Expressive Tests in Java and Groovy — read online for free the complete book (whole text) full work

    Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Spock: Up and Running: Writing Expressive Tests in Java and Groovy" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

    Light

    Font size:

    Reset

    Interval:

    Bookmark:

    Make
    Spock: Up and Running

    by Rob Fletcher

    Copyright 2017 Rob Fletcher. All rights reserved.

    Printed in the United States of America.

    Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.

    OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .

    • Editors: Nan Barber and Brian Foster
    • Production Editor: Kristen Brown
    • Copyeditor: Bob Russell, Octal Publishing, Inc.
    • Proofreader: Christina Edwards
    • Indexer: Judith McConville
    • Interior Designer: David Futato
    • Cover Designer: Karen Montgomery
    • Illustrator: Rebecca Demarest
    • May 2017: First Edition
    Revision History for the First Edition
    • 2017-05-05: First Release
    • 2019-01-18: Second Release

    See http://oreilly.com/catalog/errata.csp?isbn=9781491923290 for release details.

    The OReilly logo is a registered trademark of OReilly Media, Inc. Spock: Up and Running, the cover image, and related trade dress are trademarks of OReilly Media, Inc.

    While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.

    978-1-491-92329-0

    [LSI]

    Introduction

    Welcome to Spock: Up and Running.Im excited and privileged to be your guide as you learn about the most innovative thing to happen to testing on the Java Virtual Machine (JVM) since the first release of JUnit.

    From the time I first began writing unit tests (badly), Ive always been interested in making my tests as well-structured, readable, and straightforward as possible.I embraced the move from JUnit 3 to JUnit 4 with Hamcrest and have experimented with everything from FitNesse to Cucumber, TestNG to Jasmine, and ScalaTest to Spek.I dont think anything has made the impact on my testing style that Spock has.

    For me, Spock is absolutely the killer app of the Groovy ecosystem.Sure, GPars made concurrency easy, Gradle saved builds from XML hell, and Grails made throwing together the basics of a web app the work of minutes rather than hours.But nothing exploits Groovys dynamic style to build something that genuinely makes things easier and better as successfully as Spock.

    And Spock makes things better not just for the 80 percent of cases, but across the board.I have every respect in the world for JUnitits without doubt one of the most important innovations in the history of the JVMbut I cant think of any case I can tackle better with JUnit than I can with Spock.

    I hope you find Spock as logical, fascinating, and useful as I do.

    Meet Spock

    Spock is a test frameworksome would even say languagebuilt on top of Groovy.It was developed by Peter Niederwieser, first released in 2009, and, after a long genesis, version 1.0 was released in 2015.Version 1.1 followed in 2017, and thats the version well be using in this book.

    Although Spock builds on top of JUnits test runner its quite different syntactically.Spock enforces a behavior-driven development (BDD)-style structure.Instead of using methods to apply assertions, Spock infers that simple Boolean expressions in particular contexts behave as assertions.Instead of integrating external libraries like JMock or Mockito, Spock has its own test doubles with dedicated syntax for defining expectations and behavior (although you can use something else if you want).Spock also has syntax for defining parameterized tests that goes far beyond the capabilities of JUnits @RunWith(Parameterized.class).

    Above all, Spock specifications are very readable and expressive.Groovys brevity and lack of ceremony is harnessed to a syntax that makes tests read very well as executable documentation.

    A Short Background on Groovy

    Groovy is a dynamic, optionally typed language for the JVM that was released in 2007; as of this writing, it is currently up to version 2.4.7.Unlike some alternate JVM languages, Groovy uses very Java-like syntax.In fact, until the release of Java 8, almost all Java code was also valid Groovy code (only one obscure loop formation wasnt supported).However, Groovy adds the ability to optionally type declarations, and supports duck typing, higher-order functions, metaprogramming capabilities, runtime method dispatch, and a number of other features.

    Originally envisaged as a scripting language for the JVM, Groovy grew beyond that into a full-fledged alternate language with its own ecosystem of libraries, web frameworks, and so on.In 2012, Groovy added optional static compilation capabilities and can now target the Android platform.

    Groovys profile was boosted by two major developments: Grails, a Rails-like web framework that used Groovy code on top of an opinionated Spring and Hibernate stack; and Gradle, a build tool that combined the opinionated declarative style of Maven with the scripting capabilities of Make.When Google made Gradle the official build tool for the Android platform, an entire new community of developers was suddenly exposed to the Groovy ecosystem.

    Spock is built on top of Groovy, and Spock specifications are implemented as .groovy files.However, Spock specifications arent just JUnit tests written in Groovy.Theres a whole lot more to Spock than that.

    Syntax that would make no sense in Groovy might be valid in Spock.Spock is a domain-specific language (DSL) in the truest sense that happens to be built on top of Groovy.

    Ive deliberately avoided as much advanced Groovy as possible in the examples.Were not here to do incredible things with metaprogramming or to debate whether thats a good idea.The Groovy code used in the example specifications is, wherever possible, simple, concise, idiomatic, and unsurprising.

    Who Is This Book For?

    In the past decade, automated testing has gone from a frequently derided fringe practice to the mainstream.Resistance is futile.I think its fair to say that the majority of developers at least acknowledge the benefits of writing tests, even if they only pay lip service to the discipline of testing their own software.

    But to many developers, testing is a tough discipline to master.It feels to many people like it shouldnt be something that they should dedicate a lot of time to, but writing tests is unlike writing production software.Its an orthogonal, albeit related, skill.Beyond just the tests themselves, designing software that is amenable to testing often requires a shift in approach that can be difficult to overcome.

    Hopefully, coming to this book, you are at least convinced that automated testing sounds like a good idea.

    If youd like to begin writing tests, and Spock looks like an interesting tool for doing so, this book is for you.

    If you have tried writing tests and found it difficult to grasp how to proceed, this book is for you.

    If you write tests but find it difficult to test some aspects of your code, this book is for you.

    If you just want to write tests that are less prone to breaking as the system changes, this book is for you.

    Next page
    Light

    Font size:

    Reset

    Interval:

    Bookmark:

    Make

    Similar books «Spock: Up and Running: Writing Expressive Tests in Java and Groovy»

    Look at similar books to Spock: Up and Running: Writing Expressive Tests in Java and Groovy. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


    Reviews about «Spock: Up and Running: Writing Expressive Tests in Java and Groovy»

    Discussion, reviews of the book Spock: Up and Running: Writing Expressive Tests in Java and Groovy and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.