Java Testing with Spock

Total Page:16

File Type:pdf, Size:1020Kb

Java Testing with Spock Konstantinos Kapelonis FOREWORD BY Luke Daley MANNING 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 12345678910–EBM–212019181716 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 1FOUNDATIONS 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 2STRUCTURING SPOCK TESTS ...................................... 89 4 ■ Writing unit tests with Spock 91 5 ■ Parameterized tests 127 6 ■ Mocking and stubbing 157 PART 3SPOCK 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 1FOUNDATIONS AND BRIEF TOUR OF SPOCK ....... 1 Introducing the Spock testing framework 3 1 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]> x CONTENTS 1.5 A first look at Spock in action 18 A simple test with JUnit 18 ■ A simple test with Spock 19 Inspecting failed tests with Spock 20 1.6 Spock’s position in the Java ecosystem 23 Making Spock Groovy 24 ■ Adding Spock tests to existing projects that have JUnit tests 25 ■ Spock adoption path in a Java project 26 1.7 Comparing Spock and JUnit 27 Writing concise code with Groovy syntax 27 ■ Mocking and stubbing with no external library 27 ■ Using English sentences in Spock tests and reports 28 1.8 Summary 30 Groovy knowledge for Spock testing 31 2 2.1 What you need to know about Groovy 32 Groovy as a companion to Java 34 ■ Accessing Java classes in a Groovy script 37 ■ Declaring variables and methods in Groovy 38 ■ Writing less code with Groovy 40 2.2 Groovy Power assert as a replacement for JUnit asserts 41 Understanding how Groovy handles asserts 41 ■ Using Groovy assertions in Spock tests 44 2.3 Groovy features useful to Spock tests 46 Using map-based constructors 46 ■ Using maps and lists in Groovy 47 ■ Interpolating text with Groovy strings 50 2.4 Reading a test dataset from an external source 51 Reading a text file 51 ■ Reading an XML file 52 Reading a JSON file 53 2.5 Advanced Groovy features useful to testing 54 Using Groovy closures 55 ■ Creating test input with ObjectGraphBuilders 56 ■ Creating test input with Expando 58 2.6 Summary 61 A tour of Spock functionality 62 3 3.1 Introducing the behavior-testing paradigm 63 The setup-stimulate-assert structure of JUnit 65 ■ The given- when-then flow of Spock 67 Licensed to Stephanie Bernal <[email protected]> CONTENTS xi 3.2 Handling tests with multiple input sets 70 Existing approaches to multiple test-input parameters 72 Tabular data input with Spock 74 3.3 Isolating the class under test 76 The case of mocking/stubbing 76 ■ Stubbing fake objects with Spock 79 ■ Mocking collaborators 80 ■ Examining interactions of mocked objects 83 ■ Combining mocks and stubs in parameterized tests 86 3.4 Summary 87 PART 2STRUCTURING SPOCK TESTS .......................... 89 Writing unit tests with Spock 91 4 4.1 Understanding Spock from the ground up 91 A simple test scenario 92 ■ The given: block 94 ■ The setup: block 95 ■ The when: block 96 ■ The then: block 98 The and: block 99 ■ The expect: block 103 ■ The cleanup: block 104 4.2 Converting requirements to Spock tests 105 Explaining the feature examined in a Spock test 105 Marking the class under test inside a Spock test 106 Describing the Spock unit test as a whole 107 Revising our view of a Spock test 108 4.3 Exploring the lifecycle of a Spock test 109 Setup and cleanup of a feature 109 ■ Setup and cleanup of a specification 110 ■ Long-lived objects with the @Shared annotation 112 ■ Use of the old() method 113 4.4 Writing readable Spock tests 115 Structuring Spock tests 115 ■ Ensuring that Spock tests are self-documenting 116 ■ Modifying failure output 117 Using Hamcrest matchers 119 ■ Grouping test code further 122 4.5 Summary 125 Parameterized tests 127 5 5.1 Detecting the need for parameterized tests 128 What are parameterized tests? 130 Licensed to Stephanie Bernal <[email protected]> xii CONTENTS 5.2 Using the where: block 131 Using data tables in the where: block 133 ■ Understanding limitations of data tables 134 ■ Performing easy maintenance of data tables 135 ■ Exploring the lifecycle of the where: block 137 ■ Using the @Unroll annotation for reporting individual test runs 139 ■ Documenting parameterized tests 141 ■ Using expressions and statements in data tables 143 5.3 Using data pipes for calculating input/output parameters 144 Dynamically generated parameters 145 ■ Parameters that stay constant 147 ■ Parameters that depend on other parameters 147 5.4 Using dedicated data generators 148 Writing a custom data generator 150 ■ Using multivalued data iterators 152 5.5 Working with third-party data generators 155 5.6 Summary 156 Mocking and stubbing 157 6 6.1 Using fake collaborators 158 Using fake collaborators to isolate a class in unit tests 158 Faking classes in Spock: mocks and stubs 159 ■ Knowing when to use mocks and stubs 160 ■ Exploring a sample application for an electronic shop system 161 6.2 Controlling input to the class under test with stubs 163 Basic stubbing of return values 163 ■ Matching arguments leniently when a stubbed method is called 166 ■ Using sequential stubs with different responses for each method call 167 ■ Throwing exceptions when a stubbed method is called 168 ■ Using dynamic stubs that check arguments when responding 169 ■ Returning stubs from the responses of other stubs 172 6.3 Mocks: verifying values returned from the class under test 173 All capabilities of stubs exist in mocks as well 174 ■ Simple mocking—examining whether a method was called 174 Verifying order of interactions 176 ■ Verifying number of method calls of the mocked class 177 ■ Verifying noninteractions for multiple mocked classes 179 ■ Verifying types of arguments when a mocked method is called 181 Verifying arguments of method calls from mocked classes 182 6.4 Putting it all together: credit card charging in two steps 184 Licensed to Stephanie Bernal <[email protected]> CONTENTS xiii 6.5 Architecture considerations for effective mocking/ stubbing 188 Designing testable code that allows painless mocking 188 Understanding lenient vs. strict mocks 188 6.6 Summary 189 PART 3SPOCK IN THE ENTERPRISE .......................... 191 Integration and functional testing with Spock 193 7 7.1 Unit tests vs. integration tests vs. functional tests 194 Characteristics of the test categories 195 ■ The testing pyramid 197 ■ Spock support for integration and functional testing 198 ■ Source code organization of the examples 199 7.2 Integration testing with Spock 199 Testing a Spring application 199 ■ Narrowing down the Spring context inside Spock tests 202 ■ Directly accessing the database with Groovy SQL 204
Recommended publications
  • Star Trek" Mary Jo Deegan University of Nebraska-Lincoln, [email protected]
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by UNL | Libraries University of Nebraska - Lincoln DigitalCommons@University of Nebraska - Lincoln Sociology Department, Faculty Publications Sociology, Department of 1986 Sexism in Space: The rF eudian Formula in "Star Trek" Mary Jo Deegan University of Nebraska-Lincoln, [email protected] Follow this and additional works at: http://digitalcommons.unl.edu/sociologyfacpub Part of the Family, Life Course, and Society Commons, and the Social Psychology and Interaction Commons Deegan, Mary Jo, "Sexism in Space: The rF eudian Formula in "Star Trek"" (1986). Sociology Department, Faculty Publications. 368. http://digitalcommons.unl.edu/sociologyfacpub/368 This Article is brought to you for free and open access by the Sociology, Department of at DigitalCommons@University of Nebraska - Lincoln. It has been accepted for inclusion in Sociology Department, Faculty Publications by an authorized administrator of DigitalCommons@University of Nebraska - Lincoln. THIS FILE CONTAINS THE FOLLOWING MATERIALS: Deegan, Mary Jo. 1986. “Sexism in Space: The Freudian Formula in ‘Star Trek.’” Pp. 209-224 in Eros in the Mind’s Eye: Sexuality and the Fantastic in Art and Film, edited by Donald Palumbo. (Contributions to the Study of Science Fiction and Fantasy, No. 21). New York: Greenwood Press. 17 Sexism in Space: The Freudian Formula in IIStar Trek" MARY JO DEEGAN Space, the final frontier. These are the voyages of the starship Enterprise, its five year mission to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before. These words, spoken at the beginning of each televised "Star Trek" episode, set the stage for the fan­ tastic future.
    [Show full text]
  • Top 19 Testng Interview Questions & Answers
    https://career.guru99.com/ Guru99 Provides FREE ONLINE TUTORIAL on Various courses like Java | MIS | MongoDB | BigData | Cassandra | Web Services ------------------------------------------------------------------------------------------------------------------------------- SQLite | JSP | Informatica | Accounting | SAP Training | Python ------------------------------------------------------------------------------------------------------------------------------- Excel | ASP Net | HBase | Testing | Selenium | CCNA | NodeJS ------------------------------------------------------------------------------------------------------------------------------- TensorFlow | Data Warehouse | R Programming | Live Projects | DevOps ------------------------------------------------------------------------------------------------------------------------------- Top 19 TestNG Interview Questions & Answers Following are frequently asked questions in interviews for freshers as well as experienced TestNG professionals. 1) What is TestNG? TestNG is an automated open source testing framework. It is based on JUnit framework but is not a JUnit extension. 2) What are the TestNG features? TestNG features include TestNG uses more OO (object-oriented) and Java features It supports testing integrated classes Different Annotations are supported Separate compile time test code from data info /run time configuration Run-time configuration is flexible Flexible plug-in API For further flexibility embeds BeanShell Multi-threaded selenium testing support Supports parallel testing,
    [Show full text]
  • Hasbro's KRE-O STAR TREK Beams Into the Toy Aisle with New Building Sets and a Stop Motion Digital Short Produced by Bad Robot
    May 7, 2013 Hasbro's KRE-O STAR TREK Beams into the Toy Aisle with New Building Sets and a Stop Motion Digital Short Produced by Bad Robot The Digital Short, Utilizing KRE-O STAR TREK Building Sets Now On Shelves, Will Make its TV Broadcast Premiere May 13 on Cartoon Network PAWTUCKET, R.I.--(BUSINESS WIRE)-- Hasbro, Inc. (NASDAQ: HAS), announced the availability of the new KRE-O STAR TREK line at retail locations beginning today. Also releasing today is a stop motion animated short featuring KRE-O building sets and KREON figures based on the iconic STAR TREK film franchise. Fans can watch the video, with a new stand-alone STAR TREK storyline, now on the official KRE-O YouTube channel at youtube.com/KREO. The digital short will make its television broadcast premiere May 13 at 7:30 p.m. EST on Cartoon Network. The KRE-O STAR TREK stop motion digital short animation was produced through film director J.J. Abrams' production company, Bad Robot, with special effects for the piece created by Kelvin Optical, one of the visual effects teams also working on the soon-to-be released STAR TREK INTO DARKNESS from Paramount Pictures. "KRE-O STAR TREK marks the first time the STAR TREK universe has been available as building sets, and we are thrilled to show off the universe of KRE-O STAR TREK building sets and KREON figures with this exciting stop motion digital short from the Bad Robot team," says Kim Boyd, KRE-O senior brand director for Hasbro. "We're especially excited that kids The KRE-O STAR TREK U.S.S.
    [Show full text]
  • Proof of Concept (Poc) Selenium Web Driver Based Automation Framework
    e-ISSN (O): 2348-4470 Scientific Journal of Impact Factor (SJIF): 4.72 p-ISSN (P): 2348-6406 International Journal of Advance Engineering and Research Development Volume 4, Issue 7, July -2017 Proof of concept (Poc) selenium web driver based Automation framework B AJITH KUMAR Master of science ( Information Technology ) Department of Mathematics COLLEGE OF ENGINNERING GUINDY (CEG) Anna university ABSTRACT: To control test execution time. Software testing is a process of executing a program or application with the intent of finding the software bugs. It can also be stated as the process of validating and verifyingthat a software program or application or product: Meets the business and technical requirements that guided it’s design and development. Works as expected. KEY WORDS: SOFTWARE TESTING .AUTOMATION TESTING ,SELENIUM, SELENIUM WEBDRIVER ,AGILE TESTING , TESTNG Test automation : In software testing, test automation is the use of special software (separate from the software being tested) to control the execution of tests and the comparison of actual outcomes with predicted outcomes. Test automation can automate some repetitive but necessary tasks in a formalized testing process already in place, or add additional testing that would be difficult to perform manually. AGILE TESTING : A software testing practice that follows the principles of agile software development is called Agile Testing. Agile is an iterative development methodology, where requirements evolve through collaboration between the customer and self- organizing teams and agile aligns development with customer needs. Selenium automation tool Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser.
    [Show full text]
  • The History of Star Trek
    The History of Star Trek The original Star Trek was the brainchild of Gene Roddenberry (1921-1991), a US TV producer and scriptwriter. His idea was to make a TV series that combined the futuristic possibilities of science fiction with the drama and excitement of TV westerns (his original title for the series was ‘Wagon Train to the Stars’). Star Trek was first aired on American TV in 1966, and ran for three series. Each episode was a self-contained adventure/mystery, but they were all linked together by the premise of a gigantic spaceship, crewed by a diverse range of people, travelling about the galaxy on a five-year mission ‘to explore new life and new civilisations, to boldly go where no man has gone before’. Although not especially successful it attracted a loyal fan-base, partly male fans that liked the technological and special effects elements of the show. But the show also attracted a large number of female fans, many of whom were drawn to the complex interaction and dynamic between the three main characters, the charismatic but impetuous Captain Kirk (William Shatner), the crotchety old doctor McCoy (DeForest Kelley) and the coldly logical Vulcan science officer Spock (Leonard Nimoy). After the show was cancelled in 1969 the fans conducted a lengthy and ultimately successful campaign to resurrect the franchise. Roddenberry enjoyed success with several motion pictures, including Star Trek: The Motion Picture (1979); action-thriller Star Trek II: The Wrath of Khan (1982); Star Trek III: The Search for Spock (1984) and the more comic Star Trek IV: The Voyage Home (1986).
    [Show full text]
  • Docket No. 19-3160-Cv Plaintiff-Appellant, V. Defendants
    Case 19-3160, Document 89-1, 08/17/2020, 2909066, Page1 of 38 19-3160-cv Anas Osama Ibrahim Abdin v. CBS Broadcasting Inc., et al. UNITED STATES COURT OF APPEALS FOR THE SECOND CIRCUIT August Term 2019 (Submitted: May 14, 2020 Decided: August 17, 2020) Docket No. 19-3160-cv ANAS OSAMA IBRAHIM ABDIN, Plaintiff-Appellant, v. CBS BROADCASTING INC., NETFLIX, INC., CBS CORPORATION, CBS INTERACTIVE, INC., Defendants-Appellees. ON APPEAL FROM THE UNITED STATES DISTRICT COURT FOR THE SOUTHERN DISTRICT OF NEW YORK Before: CHIN AND CARNEY, Circuit Judges, AND DOOLEY, District Judge.* * Judge Kari A. Dooley, of the United States District Court for the District of Connecticut, sitting by designation. Case 19-3160, Document 89-1, 08/17/2020, 2909066, Page2 of 38 Appeal from a judgment of the United States District Court for the Southern District of New York (Schofield, J.), dismissing plaintiff-appellant's third amended complaint pursuant to Federal Rule of Civil Procedure 12(b)(6). Plaintiff-appellant alleged that defendants-appellees violated the Copyright Act, 17 U.S.C. § 101 et seq., by copying creative aspects from his unreleased science fiction videogame, including his use of a tardigrade -- a microscopic animal -- traveling in space, in their television series Star Trek: Discovery. The district court concluded that plaintiff-appellant's copyright claim failed as a matter of law because his videogame and the television series were not substantially similar. AFFIRMED. John Johnson and Allan Chan, Allan Chan & Associates, New York, New York, for Plaintiff-Appellant. Wook Hwang, Loeb & Loeb LLP, New York, New York, for Defendants-Appellees.
    [Show full text]
  • Star Trek the Orion Incident
    A STAR TREK FANZINE SCOTPRESS The ORION By Pac INCIDENT Deacon lr I~ IE (or SCENES OF FAMILY LIFE) by PAC DEACON Illustrated by Roo A ScoTpress pUblication Editors - Sheila Clark, Valerie Piacentini Typing - Sheila Clark Proofreading - Janet Quarton, Sheila Clark & Valerie Piacentini Printing of Masters - Janet Quarton Printing - Urban Print Distracting - Shona & Whiskers THE ORION INCIDENT in which the Enterprise crew rescues a victim of' Orion pirateD is put out by ScoTpress and is available from - Sheila Clark 6 Craigmill Cottages St;rathmartine by Dundee Scotland (C) ScoTpress September 1987. All righto reserved to the writer and artist. Anyone wishing to reprint any of the material herein is asked to obtain permission in writing first. It is understood that this applies only to original material herein. and that no attempt is made to supersede any rights held by Paramount. NBC. BBC or 8.ny other holders of copyright in STAR TREK material. ScoTpress - Sheila Clark, Valerie Piacentini. Janet Quarton & Shona lr I~ IE (or SCENES OF FAMILY LIFE) by PAC DEACON This story is respectfully and affectionately dedicated to DeForest Kelley, who finds the special magic of STAR TREK lies in the way its people came together and made a family. Also to that "nonentity" Chekov, without Whom some of the events related here would have happened rather differently .. * * * * * ttYour move, Spock.'t Kirk was really not quite sure that his friend was still with him. For the life of him he could not stop himself any longer from shifting about restlessly in his chair. The Vulcan did not usually take such a time to make up his mind what to do.
    [Show full text]
  • Taming Functional Web Testing with Spock and Geb
    Taming Functional Web Testing with Spock and Geb Peter Niederwieser, Gradleware Creator, Spock Contributor, Geb The Actors Spock, Geb, Page Objects Spock “Spock is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language. Thanks to its JUnit runner, Spock is compatible with most IDEs, build tools, and continuous integration servers. Spock is inspired from JUnit, RSpec, jMock, Mockito, Groovy, Scala, Vulcans, and other fascinating life forms. Spock (ctd.) http://spockframework.org ASL2 licence Serving mankind since 2008 Latest releases: 0.7, 1.0-SNAPSHOT Java + Groovy JUnit compatible Loves Geb Geb “Geb is a browser automation solution. It brings together the power of WebDriver, the elegance of jQuery content selection, the robustness of Page Object modelling and the expressiveness of the Groovy language. It can be used for scripting, scraping and general automation — or equally as a functional/web/acceptance testing solution via integration with testing frameworks such as Spock, JUnit & TestNG. Geb (ctd.) http://gebish.org ASL2 license Serving mankind since 2009 Latest releases: 0.7.2, 1.0-SNAPSHOT Java + Groovy Use with any test framework Loves Spock First-class page objects Page Objects “The Page Object pattern represents the screens of your web app as a series of objects. Within your web app's UI, there are areas that your tests interact with. A Page Object simply models these as objects within the test code. This reduces the amount of duplicated code and means that if the UI changes, the fix need only be applied in one place.
    [Show full text]
  • Pragmatic Unit Testingin Java 8 with Junit
    www.it-ebooks.info www.it-ebooks.info Early praise for Pragmatic Unit Testing in Java 8 with JUnit Langr, Hunt, and Thomas demonstrate, with abundant detailed examples, how unit testing with JUnit works in the real world. Beyond just showing simple iso- lated examples, they address the hard issues–things like mock objects, databases, multithreading, and getting started with automated unit testing. Buy this book and keep it on your desk, as you’ll want to refer to it often. ➤ Mike Cohn Author of Succeeding with Agile, Agile Estimating and Planning, and User Stories Applied Working from a realistic application, Jeff gives us the reasons behind unit testing, the basics of using JUnit, and how to organize your tests. This is a super upgrade to an already good book. If you have the original, you’ll find valuable new ideas in this one. And if you don’t have the original, what’s holding you back? ➤ Ron Jeffries www.ronjeffries.com Rational, balanced, and devoid of any of the typical religious wars surrounding unit testing. Top-drawer stuff from Jeff Langr. ➤ Sam Rose This book is an excellent resource for those new to the unit testing game. Experi- enced developers should also at the very least get familiar with the very helpful acronyms. ➤ Colin Yates Principal Architect, QFI Consulting, LLP www.it-ebooks.info We've left this page blank to make the page numbers the same in the electronic and paper books. We tried just leaving it out, but then people wrote us to ask about the missing pages.
    [Show full text]
  • Comparative Analysis of Junit and Testng Framework
    International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 05 Issue: 05 | May-2018 www.irjet.net p-ISSN: 2395-0072 Comparative Analysis of JUnit and TestNG framework Manasi Patil1, Mona Deshmukh2 Student, Dept. of MCA, VES Institute of Technology, Maharashtra, India1 Professor, Dept. of MCA, VES Institute of Technology, Maharashtra, India2 ---------------------------------------------------------------------***--------------------------------------------------------------------- Abstract - Testing is an important phase in SDLC, Testing It is flexible than Junit and supports parametrization, parallel can be manual or automated. Nowadays Automation testing is execution and data driven testing. widely used to find defects and to ensure the correctness and The Table – 1 compares different functionalities of TestNG completeness of the software. Open source framework can be and JUnit framework. used for automation testing such as Robotframework, Junit, Spock, NUnit, TestNG, Jasmin, Mocha etc. This paper compares Table -1: Functionality TestNG vs JUnit JUnit and TestNG based on their features and functionalities. Key Words: JUnit, TestNG, Automation Framework, Functionality TestNG JUnit Automation Testing, Selenium TestNG, Selenium JUnit Yes 1. INTRODUCTION Support Annotations Yes Yes Support Test Suit Initialization Yes Testing a software manually is tedious work, and takes lot of No time and efforts. Automation saves lot of time and money, Support for Tests groups Yes also it increases the test coverage
    [Show full text]
  • Smart BDD Testing Using Cucumber and Jacoco
    www.hcltech.com Smart BDD Testing Using Cucumber and JaCoCo Business assurance $ Testing AuthOr: Arish Arbab is a Software Engineer at HCL Singapore Pte Limited, having expertize on Agile GUI/API Automation methodologies. WHITEPAPER ApriL 2015 SMART BDD TESTING USING CUCUMBER AND JACOCO | APRIL 2015 TABLE OF CONTENTS INTRODUCTION 3 PROBLEM FACED 3 SOLUTION APPROACH 4 BENEFITS 6 IMPROVEMENTS 7 APPLICABILITY TO OTHER PROJECTS 7 UPCOMING FEATURES 7 REFERENCES 8 APPRECIATIONS RECEIVED 8 ABOUT HCL 9 © 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED. 2 SMART BDD TESTING USING CUCUMBER AND JACOCO | APRIL 2015 INTRODUCTION Behavioral Driven Development (BDD) testing uses natural language to describe the “desired behavior” of the system that can be understood by the developer, tester and the customer. It is a synthesis and refinement of practices stemming from TDD and ATDD. It describes behaviors in a single notation that is directly accessible to domain experts, testers and developers for improving communication. It focuses on implementing only those behaviors, which contribute most directly to the business outcomes for optimizing the scenarios. PROBLEM FACED By using the traditional automation approach, and if given a summary report of automated tests to the business analysts, then it is guaranteed that the report would be met with a blank expression. This makes it tricky to prove that the tests are correct— do they match the requirement and, if this changes, what tests need to change to reflect this? The whole idea behind BDD is to write tests in plain English, describing the behaviors of the thing that you are testing.
    [Show full text]
  • Bringing Test-Driven Development to Web Service Choreographies
    Journal of Systems and Software • October 2014 • http://www.sciencedirect.com/science/article/pii/S016412121400209X Bringing Test-Driven Development to Web Service Choreographies Felipe Besson,Paulo Moura,Fabio Kon Dejan Milojicic Department of Computer Science Hewlett Packard Laboratories University of São Paulo Palo Alto, USA {besson, pbmoura, kon}@ime.usp.br [email protected] Abstract Choreographies are a distributed approach for composing web services. Compared to orchestrations, which use a centralized scheme for distributed service management, the interaction among the chore- ographed services is collaborative with decentralized coordination. Despite the advantages, choreography development, including the testing activities, has not yet evolved sufficiently to support the complexity of the large distributed systems. This substantially impacts the robustness of the products and overall adoption of choreographies. The goal of the research described in this paper is to support the Test-Driven Development (TDD) of choreographies to facilitate the construction of reliable, decentralized distributed systems. To achieve that, we present Rehearsal, a framework supporting the automated testing of chore- ographies at development-time. In addition, we present a choreography development methodology that guides the developer on applying TDD using Rehearsal. To assess the framework and the methodology, we conducted an exploratory study with developers, whose result was that Rehearsal was considered very helpful for the application of TDD and that the methodology helped the development of robust choreographies. Keywords: Automated testing, Test-Driven Development, Web service choreographies I. Introduction Service-Oriented Architecture (SOA) is a set of principles and methods that uses services as the building blocks for the development of distributed applications.
    [Show full text]