ebook img

Java Testing with Spock PDF

306 Pages·2016·12.289 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Java Testing with Spock

Konstantinos Kapelonis F Luke Daley OREWORD BY M A N N I N G Java Testing with Spock Licensed to Stephanie Bernal <[email protected]> ii Licensed to Stephanie Bernal <[email protected]> Java Testing with Spock KONSTANTINOS KAPELONIS MANNING SHELTER ISLAND Licensed to Stephanie Bernal <[email protected]> iv For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: [email protected] ©2016 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without elemental chlorine. Manning Publications Co. Development editors: Susan Conant 20 Baldwin Road Dan Maharry PO Box 761 Technical development editor: Keith Conant Shelter Island, NY 11964 Copyeditor: Sharon Wilkey Proofreaders: Melody Dolab Toma Mulligan Technical proofreader: Francesco Bianchi Typesetter: Marija Tudor Cover designer: Marija Tudor ISBN: 9781617292538 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – EBM – 21 20 19 18 17 16 Licensed to Stephanie Bernal <[email protected]> To Maria, for enduring my endless writing sessions Licensed to Stephanie Bernal <[email protected]> Licensed to Stephanie Bernal <[email protected]> brief contents PART 1 FOUNDATIONS AND BRIEF TOUR OF SPOCK ................... 1 1 ■ Introducing the Spock testing framework 3 2 ■ Groovy knowledge for Spock testing 31 3 ■ A tour of Spock functionality 62 PART 2 STRUCTURING SPOCK TESTS ...................................... 89 4 ■ Writing unit tests with Spock 91 5 ■ Parameterized tests 127 6 ■ Mocking and stubbing 157 PART 3 SPOCK IN THE ENTERPRISE ...................................... 191 7 ■ Integration and functional testing with Spock 193 8 ■ Spock features for enterprise testing 224 vii Licensed to Stephanie Bernal <[email protected]> viii BRIEF CONTENTS Licensed to Stephanie Bernal <[email protected]> contents foreword xv preface xvii acknowledgments xix about this book xxi about the cover illustration xxiv PART 1 FOUNDATIONS AND BRIEF TOUR OF SPOCK ....... 1 1 Introducing the Spock testing framework 3 1.1 What is Spock? 4 Mocking and stubbing 5 ■ Behavior-driven development 5 Spock’s design features 5 ■ Spock’s coding features 6 1.2 The need for a testing framework 8 Spock as an enterprise-ready test framework 9 ■ Common ways to handle enterprise complexity 13 1.3 Spock: the groovier testing framework 15 Asserts vs. Assertions 15 ■ Agnostic testing of Java and Groovy 15 ■ Taking advantage of Groovy tricks in Spock tests 16 1.4 Getting an overview of Spock’s main features 16 Enterprise testing 17 ■ Data-driven tests 17 Mocking and stubbing 17 ix Licensed to Stephanie Bernal <[email protected]>

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.