Smarter Testing With Spock



Similar documents
Sonatype CLM for Maven. Sonatype CLM for Maven

Chapter 1: Web Services Testing and soapui

Automated Integration Testing & Continuous Integration for webmethods

Build Automation for Mobile. or How to Deliver Quality Apps Continuously. Angelo Rüggeberg

Database Migration Plugin - Reference Documentation

<Insert Picture Here> TDD on a Coherence project

Unit Testing. and. JUnit

Continuous Integration: A case study

GContracts Programming by Contract with Groovy. Andre Steingress

Agile ALM. Lightweight tools and Agile strategies MANNING MICHAEL HUTTERMANN. Shelter Island

Hudson configuration manual

JUnit. Introduction to Unit Testing in Java

Mastering Continuous Integration with Jenkins

Load Testing with JMeter

Software infrastructure for Java development projects

Unit Testing JUnit and Clover

Jenkins: The Definitive Guide

Java Software Quality Tools and techniques

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

November 12 th 13 th London: Mastering Continuous Integration with Jenkins

INCREASE YOUR WEBMETHODS ROI WITH AUTOMATED TESTING. Copyright 2015 CloudGen, LLC

Test Automation Integration with Test Management QAComplete

Testing: Python, Java, Groovy, etc.

Agile Development with Groovy and Grails. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Trend Micro Worry- Free Business Security st time setup Tips & Tricks

Viewpoint. Choosing the right automation tool and framework is critical to project success. - Harsh Bajaj, Technical Test Lead ECSIVS, Infosys

Author: Sascha Wolski Sebastian Hennebrueder Tutorials for Struts, EJB, xdoclet and eclipse.

Organising Massive Test bol.com. Jeroen Ruijgers and Viktor Clerc

Sonatype CLM Enforcement Points - Continuous Integration (CI) Sonatype CLM Enforcement Points - Continuous Integration (CI)

Jenkins on Windows with StreamBase

Beginners guide to continuous integration. Gilles QUERRET Riverside Software

Testing Tools Content (Manual with Selenium) Levels of Testing

Build management & Continuous integration. with Maven & Hudson

Jenkins User Conference Herzelia, July #jenkinsconf. Testing a Large Support Matrix Using Jenkins. Amir Kibbar HP

TeamCity A Professional Solution for Delivering Quality Software, on Time

Introduction to Programming Tools. Anjana & Shankar September,2010

A-Team Tech Talk Series. SOA Unit Testing. Olivier LeDiouris, Oracle A-Team

Lab work Software Testing

Developing modular Java applications

Open Source in Mobile Test Automation. Ru Cindrea - Altom ru@altom.ro

CI:IRL. By Beth Tucker Long

Continuous Delivery for Alfresco Solutions. Satisfied customers and happy developers with!! Continuous Delivery!

Continuous Delivery. Alejandro Ruiz

Apache Gump. Continuous Integration on Steroids. Apache Software Foundation Building FOSDEM 2005

Escaping the Works-On-My-Machine badge Continuous Integration with PDE Build and Git

the first thing that comes to mind when you think about unit testing? If you re a Java developer, it s probably JUnit, since the

WHITE PAPER. Getting started with Continuous Integration in software development. - Amruta Kumbhar, Madhavi Shailaja & Ravi Shankar Anupindi

Building, Testing & Deploying Android Apps with Jenkins

Unit Testing webmethods Integrations using JUnit Practicing TDD for EAI projects

Rapid Application Development. and Application Generation Tools. Walter Knesel

Installing the Android SDK

Table of Contents. LESSON: The JUnit Test Tool...1. Subjects...2. Testing What JUnit Provides...4. JUnit Concepts...5

Building, testing and deploying mobile apps with Jenkins & friends

SPRING INTERVIEW QUESTIONS

Continuous Integration For Fusion Middleware

soapui Product Comparison

Setting Up Your Android Development Environment. For Mac OS X (10.6.8) v1.0. By GoNorthWest. 3 April 2012

Agile Best Practices and Patterns for Success on an Agile Software development project.

SOA-14: Continuous Integration in SOA Projects Andreas Gies

Practicing Continuous Delivery using Hudson. Winston Prakash Oracle Corporation

CoProc2. 1 Overview. Contents. Eclipse/DataPower CoProcessor

Robotium Automated Testing for Android

<Insert Picture Here> Introducing Hudson. Winston Prakash. Click to edit Master subtitle style

How to Create an Android Application using Eclipse on Windows 7

TESTING WITH JUNIT. Lab 3 : Testing

CUT YOUR GRAILS APPLICATION TO PIECES

XMLVend Protocol Message Validation Suite

Grails: Accelerating J2EE Application Development

Continuous Integration

My DevOps Journey by Billy Foss, Engineering Services Architect, CA Technologies

Continuous Integration For Real: The Perforce Java Platform. Hamish Reid Perforce Software Inc.

Meister Going Beyond Maven

Grails 1.1. Web Application. Development. Reclaiming Productivity for Faster. Java Web Development. Jon Dickinson PUBLISHING J MUMBAI BIRMINGHAM

<Insert Picture Here> What's New in NetBeans IDE 7.2

Tutorial 7 Unit Test and Web service deployment

CS108, Stanford Handout #33 Young. HW5 Web

SELF SERVICE RESET PASSWORD MANAGEMENT DATABASE REPLICATION GUIDE

Glassbox: Open Source and Automated Application Troubleshooting. Ron Bodkin Glassbox Project Leader

Maven or how to automate java builds, tests and version management with open source tools

Automate APIs with Groovy Script

JUnit Automated Software Testing Framework. Jeff Offutt. SWE 437 George Mason University Thanks in part to Aynur Abdurazik. What is JUnit?

Slides prepared by : Farzana Rahman TESTING WITH JUNIT IN ECLIPSE

JDemo - Lightweight Exploratory Developer Testing

Event-driven plugins with Grails 3. Göran Ehrsson, Technipelago AB

Continuous Integration and Delivery at NSIDC

Automated performance testing using Maven & JMeter. George Barnett, Atlassian Software

Unit Testing with zunit

In depth study - Dev teams tooling

Jenkins Continuous Build System. Jesse Bowes CSCI-5828 Spring 2012

Time-to-live. Adrian Colyer CTO SpringSource

Jemmy tutorial. Introduction to Jemmy testing framework. Pawel Prokop. March 14,

BDD in Action. Building Software Right Building the Right Software

Transcription:

Smarter Testing With Spock Peter Niederwieser Principal Engineer,Gradleware

What we ll talk about Spock?! State Based Testing Data Driven Testing Interaction Based Testing Spock Extensions More Cool Stuff

Spock?!

Spock is... A developer testing framework... for Groovy and Java applications... based on Groovy... fully compatible with JUnit... but going beyond!

Spock Can... Reduce the lines of test code Make tests more readable Turn tests into specifications Be extended in powerful ways Bring back the fun to testing!

Getting Started Homepage http://spockframework.org Source Code https://github.com/spockframework/spock Spock Web Console http://meet.spockframework.org Spock Example Project http://downloads.spockframework.org https://github.com/spockframework/spock/tree/groovy-1.8/ spock-example Slides and Code for this Presentation https://github.com/spockframework/smarter-testing-with-spock

Who s Using Spock? Gradle Grails GPars Geb Grails Plugin Collective Apache Tapestry Griffon Spock Spring?

Who s Using Spock? (2) be2 CTI Digital eharmony Smarter Ecommerce BSkyB bemoko Energized Work SystemsForge IntelliGrape Software Software Projects Gennemtænkt IT

State Based Testing

State Based Testing Classical Unit Testing Arrange Act Assert Given-When-Then

State Based Testing Classical Unit Testing Arrange Act Assert Given-When-Then Show me the code!

Recap: State Based Testing Blocks setup: cleanup: expect: given: when: then: where: and: Fixture Methods setup() cleanup() setupspec() cleanupspec() Instance and @Shared fields old() and thrown()

Data Driven Testing

Data Driven Testing Test the same behavior... with varying data!

Data Driven Testing Test the same behavior... with varying data! Show me the code!

Recap: Data Driven Testing where: block Data tables External data sources @Unroll

Interaction Based Testing

Interaction Based Testing Design and test how your objects communicate Mocking frameworks to the rescue Spock comes with its own mocking framework

Interaction Based Testing Design and test how your objects communicate Mocking frameworks to the rescue Show me the code! Spock comes with its own mocking framework

Recap: Interaction Based Testing Creating def sub = Mock(Subscriber) Subscriber sub = Mock() Mocking 1 * sub.receive("msg") (1..3) * sub.receive(_) (1.._) * sub.receive(_ as String) 1 * sub.receive(!null) 1 * sub.receive({it.contains("m")}) 1 * _./rec.*/("msg")

Recap: Interaction Based Testing (2) Stubbing // now returns status code String receive(string msg) {... } sub.receive(_) >> "ok" sub.receive(_) >>> ["ok", "ok", "fail"] sub.receive(_) >>> { msg -> msg.size() > 3? "ok" : "fail" } Mocking and Stubbing 3 * sub.receive(_) >>> ["ok", "ok", "fail"] Impressing your friends (_.._) * _._(*_) >> _

Spock Extensions

Spock Extensions Listeners Interceptors Annotation-driven extensions Global extensions

Built-in Extensions @Ignore @IgnoreRest @FailsWith @Timeout @AutoCleanup @Stepwise @RevertMetaClass @Rule

Built-in Extensions @Ignore @IgnoreRest @FailsWith @Timeout @AutoCleanup Show me the code! @Stepwise @RevertMetaClass @Rule

External Extensions spock-grails spock-spring spock-guice spock-tapestry spock-unitils spock-griffon spock-arquillian spock-extensions http://github.com/robfletcher/spock-extensions

Grails Extension http://grails.org/plugin/spock https://github.com/spockframework/spockgrails grails install plugin spock 0.6 grails test-app grails test-app integration:spock C*

Grails Extension (2) @TestFor(PersonController) @Mock(Person) class PersonControllerSpec extends Specification { def "domain mocking"() { setup: mockdomain(person) when: new Person(name: name).save() then: Person.findByName(name)!= null } } where: name = "bill"

Spring Extension class InjectionExamples extends Specification { @Autowired IService1 bytype @Resource IService1 byname } @Autowired ApplicationContext context

Other Cool Stuff

Configuring Spock ~/.spock/spockconfig.groovy, or on class path, or with -Dspock.configuration runner { filterstacktrace false include Fast exclude Slow optimizerunorder true } @Fast class MyFastSpec extends Specification { def "I m fast as hell!"() { expect: true } } @Slow def "sorry, can t keep up..."() { expect: false }

Tooling Eclipse, IDEA Ant, Maven, Gradle Jenkins, Bamboo, TeamCity Spock runs everywhere JUnit and Groovy run!

Spock Under The Hood You write... a = 1; b = 2; c = 4 expect: sum(a, b) == c Spock generates... def rec = new ValueRecorder() verifier.expect( rec.record(rec.record(sum(rec.record(a), rec.record(b)) == rec.record(c))) You see... sum(a, b) == c 3 1 2 4 false

Q&A Homepage http://spockframework.org Source Code https://github.com/spockframework/spock Spock Web Console http://meet.spockframework.org Spock Example Project http://downloads.spockframework.org https://github.com/spockframework/spock/tree/groovy-1.8/ spock-example Slides and Code for this Presentation https://github.com/spockframework/smarter-testing-with-spock