SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
Spock
A Unit Testing
Framework
Presented By: Deepak Mehra
Senior Software Consultant
Knoldus Inc.
About Knoldus
Knoldus is a technology consulting firm with focus on modernizing the digital systems
at the pace your business demands.
DevOps
Functional. Reactive. Cloud Native
01 What is Spock Framework?
02 Spock Features
03 Why Spock Framework?
04 What is Specification?
05 Mocking and Stubbing
05050505
05
Our Agenda
06 JUnit vs Spock
What is Spock Framework?
● Spock is a BDD-style developer testing and specification framework for Java and
Groovy applications.
● Spock combines unit testing, mocking stubbing and business driven development
all into one framework so you don’t have to download/include additional libraries
in your build.
● Everything is inbuilt in Spock framework, it was inspired by JUnit framework only
and JUnit is also used under the hood.
● We will write the code in Java but we will test the code in Groovy.
Spock Features
● Highly expressive – Test cases can be expressed in terms of given, when and then
blocks.
● Compatible with most IDEs – It is compatible with all the leading IDEs in the
market.
● Compatible with build tools – Compatible with Maven as well as Gradle.
● Compatible with Continuous integration servers – The JUnit runner makes it
compatible with all the continuous integration servers out there.
Why Spock Framework?
● Highly Expressive Specification Language.
● Compatibility with leading IDEs.
● Test cases are written in Groovy which is pretty much similar to Java and also a
JVM based language.
● One framework for all types of test cases, no other libraries are required to write
test cases.
● Expressive than the typical Junit.
● Easy data driven testing which was very verbose in Junit
What is Specification?
● A specification is represented as a Groovy class that extends from
spock.lang.Specification.
● The name of a specification usually relates to the system or system operation
described by the specification.
● Class Specification contains a number of useful methods for writing specifications.
Furthermore it instructs JUnit to run specification with Sputnik, Spock’s JUnit runner.
● Thanks to Sputnik, Spock specifications can be run by most modern Java IDEs and
build tools.
Demo
References
http://spockframework.org
http://webconsole.spockframework.org
https://blog.knoldus.com/introduction-to-spock-a-unit-testing-framework/
https://github.com/deepakmehra10/spock-demo
Thank You!
@deeps_1991
deepak.mehra@knoldus.
com
https://www.linkedin.co
m/in/deepak-mehra-69
478843/

Contenu connexe

Tendances

Understand regression testing
Understand regression testingUnderstand regression testing
Understand regression testing
gaoliang641
 
Software Testing Life Cycle
Software Testing Life CycleSoftware Testing Life Cycle
Software Testing Life Cycle
Udayakumar Sree
 

Tendances (20)

Understand regression testing
Understand regression testingUnderstand regression testing
Understand regression testing
 
Defect life cycle and Defect Status Life Cycle
Defect life cycle and Defect Status Life CycleDefect life cycle and Defect Status Life Cycle
Defect life cycle and Defect Status Life Cycle
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
devops
devops devops
devops
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 
DCSF19 Containers for Beginners
DCSF19 Containers for BeginnersDCSF19 Containers for Beginners
DCSF19 Containers for Beginners
 
Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Agile QA and Testing process
Agile QA and Testing processAgile QA and Testing process
Agile QA and Testing process
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Geb presentation
Geb presentationGeb presentation
Geb presentation
 
Security in CI/CD Pipelines: Tips for DevOps Engineers
Security in CI/CD Pipelines: Tips for DevOps EngineersSecurity in CI/CD Pipelines: Tips for DevOps Engineers
Security in CI/CD Pipelines: Tips for DevOps Engineers
 
Selenium 4 with Simon Stewart [Webinar]
Selenium 4 with Simon Stewart [Webinar]Selenium 4 with Simon Stewart [Webinar]
Selenium 4 with Simon Stewart [Webinar]
 
[MoT SP #1] PRISMA para Testes Baseados em Risco
[MoT SP #1] PRISMA para Testes Baseados em Risco[MoT SP #1] PRISMA para Testes Baseados em Risco
[MoT SP #1] PRISMA para Testes Baseados em Risco
 
Software Testing Life Cycle
Software Testing Life CycleSoftware Testing Life Cycle
Software Testing Life Cycle
 
Latest Manual Testing Interview Questions and Answers 2015 - H2kinfosys
Latest Manual Testing Interview Questions and Answers 2015 - H2kinfosys Latest Manual Testing Interview Questions and Answers 2015 - H2kinfosys
Latest Manual Testing Interview Questions and Answers 2015 - H2kinfosys
 
Geb with spock
Geb with spockGeb with spock
Geb with spock
 
Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
 

Similaire à Introduction to Spock: A Unit Testing Framework

Curious Coders Java Web Frameworks Comparison
Curious Coders Java Web Frameworks ComparisonCurious Coders Java Web Frameworks Comparison
Curious Coders Java Web Frameworks Comparison
Hamed Hatami
 

Similaire à Introduction to Spock: A Unit Testing Framework (20)

OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScript
 
Java Programming 100 Programming Challenges
Java Programming 100 Programming ChallengesJava Programming 100 Programming Challenges
Java Programming 100 Programming Challenges
 
Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...
Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...
Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...
 
Introduction to Spring & Spring BootFramework
Introduction to Spring  & Spring BootFrameworkIntroduction to Spring  & Spring BootFramework
Introduction to Spring & Spring BootFramework
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
 
Efficient mobile automation
Efficient mobile automationEfficient mobile automation
Efficient mobile automation
 
TDD on OSGi, in practice.
TDD on OSGi, in practice.TDD on OSGi, in practice.
TDD on OSGi, in practice.
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
TDD with Spock @xpdays_ua
TDD with Spock @xpdays_uaTDD with Spock @xpdays_ua
TDD with Spock @xpdays_ua
 
Run your Java code on Cloud Foundry
Run your Java code on Cloud FoundryRun your Java code on Cloud Foundry
Run your Java code on Cloud Foundry
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
 
LF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat17_OpenAPI and gRPC Side-by-SideLF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat17_OpenAPI and gRPC Side-by-Side
 
Node.js vs. java
Node.js vs. javaNode.js vs. java
Node.js vs. java
 
Curious Coders Java Web Frameworks Comparison
Curious Coders Java Web Frameworks ComparisonCurious Coders Java Web Frameworks Comparison
Curious Coders Java Web Frameworks Comparison
 
Node.js vs. java which one should you choose for backend development
Node.js vs. java  which one should you choose for backend development Node.js vs. java  which one should you choose for backend development
Node.js vs. java which one should you choose for backend development
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
TDD with Python and App Engine
TDD with Python and App EngineTDD with Python and App Engine
TDD with Python and App Engine
 

Plus de Knoldus Inc.

Plus de Knoldus Inc. (20)

Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable Testing
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose Kubernetes
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptx
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptx
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptx
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptx
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake Presentation
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics Presentation
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIs
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II Presentation
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRA
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Introduction to Spock: A Unit Testing Framework

  • 1. Spock A Unit Testing Framework Presented By: Deepak Mehra Senior Software Consultant Knoldus Inc.
  • 2. About Knoldus Knoldus is a technology consulting firm with focus on modernizing the digital systems at the pace your business demands. DevOps Functional. Reactive. Cloud Native
  • 3. 01 What is Spock Framework? 02 Spock Features 03 Why Spock Framework? 04 What is Specification? 05 Mocking and Stubbing 05050505 05 Our Agenda 06 JUnit vs Spock
  • 4. What is Spock Framework? ● Spock is a BDD-style developer testing and specification framework for Java and Groovy applications. ● Spock combines unit testing, mocking stubbing and business driven development all into one framework so you don’t have to download/include additional libraries in your build. ● Everything is inbuilt in Spock framework, it was inspired by JUnit framework only and JUnit is also used under the hood. ● We will write the code in Java but we will test the code in Groovy.
  • 5. Spock Features ● Highly expressive – Test cases can be expressed in terms of given, when and then blocks. ● Compatible with most IDEs – It is compatible with all the leading IDEs in the market. ● Compatible with build tools – Compatible with Maven as well as Gradle. ● Compatible with Continuous integration servers – The JUnit runner makes it compatible with all the continuous integration servers out there.
  • 6. Why Spock Framework? ● Highly Expressive Specification Language. ● Compatibility with leading IDEs. ● Test cases are written in Groovy which is pretty much similar to Java and also a JVM based language. ● One framework for all types of test cases, no other libraries are required to write test cases. ● Expressive than the typical Junit. ● Easy data driven testing which was very verbose in Junit
  • 7. What is Specification? ● A specification is represented as a Groovy class that extends from spock.lang.Specification. ● The name of a specification usually relates to the system or system operation described by the specification. ● Class Specification contains a number of useful methods for writing specifications. Furthermore it instructs JUnit to run specification with Sputnik, Spock’s JUnit runner. ● Thanks to Sputnik, Spock specifications can be run by most modern Java IDEs and build tools.