SlideShare a Scribd company logo
Grails Unit Testing By:-  Uday & Imran
Agenda Testing overview
Understanding Unit Testing
Goals of Unit Testing
Spock Unit Testing
Writing Unit test cases
Demo
Exercise
What do we test ? What a program is supposed to do  ==  What the program actually does
Motivation People are not perfect We make errors in design and code Testing is an investment Over the time the tests build, the early investment in writing test cases pays dividends later as the size of the application grows.
A way of thinking Designing and coding are creative
Testing is destructive.The primary goal is to break the software
Very often the same person does coding and testing
Need 'split personality': when you start testing, become  paranoid  and  malicious.  Surprisingly hard to do: people don't like finding out that they make mistakes.
We have more code base to handle
Testing Testing  is a process of executing software with the intent of finding errors.
Good Testing  has high probability of finding as-yet-undiscovered errors
Successful Testing  discovers errors If it did not find any errors, need to ask whether our testing approach is good or not
Testing needs to be the integral part at each level of development Unit testing (white box)
Integration testing (white box)
Functional testing (black box)
Acceptance testing
Understanding Unit Testing Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
A unit is the smallest testable part of an application.
Each test case is independent from the others: substitutes like method stubs, mock objects, can be used to assist testing a module in isolation.
A unit test provides a strict, written contract that the piece of code must satisfy.
It tests individual methods or blocks of code without considering for surrounding infrastructure.
It is integral part of the development, so developers write unit test cases.
Shortcomings of Unit Testing Test cases ‐written to suit programmer’s implementation (not necessarily specification)
The actual database or external file is never tested directly by TDD.
It is highly reliant on Refactoring and Programmer skills
Not every code is testable.
Advantages of Unit Testing Facilitates change
Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly
Simplifies integration
Unit testing may reduce uncertainty in the units themselves and can be used in a bottom-up testing style approach.By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier.
Documentation
Unit testing provides a sort of living documentation of the system
Design
When software is developed using a test-driven approach, the unit test may take the place of formal design. Each unit test can be seen as a design element specifying classes, methods, and observable behaviour.
Quality Improves the quality, readability and testability of the code
Spock A developer testing framework for Java and Groovy application
Based on Groovy

More Related Content

What's hot (20)

PPT
Unit testing with java
Dinuka Malalanayake
 
PPTX
Tdd & unit test
GomathiNayagam S
 
PPT
Automated Unit Testing
Mike Lively
 
PPSX
Junit
FAROOK Samath
 
PDF
How and what to unit test
Eugenio Lentini
 
PPT
Junit and testNG
Марія Русин
 
PDF
Test driven development - JUnit basics and best practices
Narendra Pathai
 
PDF
All about unit testing using (power) mock
Pranalee Rokde
 
PDF
C++ Unit Test with Google Testing Framework
Humberto Marchezi
 
PDF
TestNG vs. JUnit4
Andrey Oleynik
 
PPTX
Junit 4.0
pallavikhandekar212
 
PPTX
.Net Unit Testing with Visual Studio 2010
kgayda
 
PPT
Google mock for dummies
Harry Potter
 
PPT
Testing and Mocking Object - The Art of Mocking.
Deepak Singhvi
 
PPTX
Unit test
Tran Duc
 
PPT
Simple Unit Testing With Netbeans 6.1
Kiki Ahmadi
 
ODP
Testing In Java
David Noble
 
PPTX
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
PPTX
TestNG vs JUnit: cease fire or the end of the war
Oleksiy Rezchykov
 
PDF
Unit Testing
Scott Leberknight
 
Unit testing with java
Dinuka Malalanayake
 
Tdd & unit test
GomathiNayagam S
 
Automated Unit Testing
Mike Lively
 
How and what to unit test
Eugenio Lentini
 
Junit and testNG
Марія Русин
 
Test driven development - JUnit basics and best practices
Narendra Pathai
 
All about unit testing using (power) mock
Pranalee Rokde
 
C++ Unit Test with Google Testing Framework
Humberto Marchezi
 
TestNG vs. JUnit4
Andrey Oleynik
 
.Net Unit Testing with Visual Studio 2010
kgayda
 
Google mock for dummies
Harry Potter
 
Testing and Mocking Object - The Art of Mocking.
Deepak Singhvi
 
Unit test
Tran Duc
 
Simple Unit Testing With Netbeans 6.1
Kiki Ahmadi
 
Testing In Java
David Noble
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
TestNG vs JUnit: cease fire or the end of the war
Oleksiy Rezchykov
 
Unit Testing
Scott Leberknight
 

Similar to Grails unit testing (20)

PPTX
Unit/Integration Testing using Spock
Anuj Aneja
 
PDF
Unit testing basic
Yuri Anischenko
 
PDF
Spock: Test Well and Prosper
Ken Kousen
 
PPT
Spock
Gajraj Kalburgi
 
PPT
Security Testing
Kiran Kumar
 
PDF
Unit testing - A&BP CC
JWORKS powered by Ordina
 
PPT
Svcc Groovy Testing
Andres Almiray
 
PPTX
Java Unit Test - JUnit
Aktuğ Urun
 
PPTX
Smarter Testing with Spock
Dmitry Voloshko
 
PDF
Por qué usar Spock en lugar de JUnit / Mockito para tus tests Java - Codemoti...
Andrés Viedma Peláez
 
ODP
Groovy Testing
Davide Rossi
 
PDF
#codemotion2016: Everything you should know about testing to go with @pedro_g...
Sergio Arroyo
 
PDF
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
Christian Baranowski
 
PPTX
Grails 1.1 Testing - Unit, Integration & Functional
2Paths Solutions Ltd.
 
PPTX
Testing 101
Noam Barkai
 
PDF
Unit Testing
Stanislav Tiurikov
 
PPTX
Smarter Testing With Spock
IT Weekend
 
PDF
Bdd for-dso-1227123516572504-8
Frédéric Delorme
 
PPT
Boosting Your Testing Productivity with Groovy
James Williams
 
Unit/Integration Testing using Spock
Anuj Aneja
 
Unit testing basic
Yuri Anischenko
 
Spock: Test Well and Prosper
Ken Kousen
 
Security Testing
Kiran Kumar
 
Unit testing - A&BP CC
JWORKS powered by Ordina
 
Svcc Groovy Testing
Andres Almiray
 
Java Unit Test - JUnit
Aktuğ Urun
 
Smarter Testing with Spock
Dmitry Voloshko
 
Por qué usar Spock en lugar de JUnit / Mockito para tus tests Java - Codemoti...
Andrés Viedma Peláez
 
Groovy Testing
Davide Rossi
 
#codemotion2016: Everything you should know about testing to go with @pedro_g...
Sergio Arroyo
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
Christian Baranowski
 
Grails 1.1 Testing - Unit, Integration & Functional
2Paths Solutions Ltd.
 
Testing 101
Noam Barkai
 
Unit Testing
Stanislav Tiurikov
 
Smarter Testing With Spock
IT Weekend
 
Bdd for-dso-1227123516572504-8
Frédéric Delorme
 
Boosting Your Testing Productivity with Groovy
James Williams
 
Ad

Recently uploaded (20)

PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
July Patch Tuesday
Ivanti
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
July Patch Tuesday
Ivanti
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Ad

Grails unit testing

Editor's Notes