SlideShare a Scribd company logo
1 of 76
Test First,
Refresh Second
                Test-Driven Development with




Tim Berglund
October, 2009
TDD
Failure to Write Tests?
KINDS OF TESTING
KINDS OF TESTING


   UNIT TESTING
KINDS OF TESTING


   UNIT TESTING
      XUNIT
KINDS OF TESTING
KINDS OF TESTING

INTEGRATION TESTING
KINDS OF TESTING

INTEGRATION TESTING
  XUNIT EXTENSIONS
KINDS OF TESTING

INTEGRATION TESTING
  XUNIT EXTENSIONS
      TESTNG
KINDS OF TESTING
KINDS OF TESTING

FUNCTIONAL TESTING
KINDS OF TESTING

FUNCTIONAL TESTING
KINDS OF TESTING

FUNCTIONAL TESTING
UNIT TESTS
EXECUTABLE
ISOLATED
AUTOMATED
ISOLATED?
WEB APP ISOLATION
  CHALLENGES
WEB APP ISOLATION
  CHALLENGES
      DATABASE
WEB APP ISOLATION
  CHALLENGES
       DATABASE
   SERVLET CONTAINER
WEB APP ISOLATION
  CHALLENGES
       DATABASE
   SERVLET CONTAINER
   HTTP INTERACTION
WEB APP ISOLATION
  CHALLENGES
       DATABASE
   SERVLET CONTAINER
   HTTP INTERACTION
    PAGE RENDERING
WEB APP ISOLATION
  CHALLENGES
          DATABASE
     SERVLET CONTAINER
     HTTP INTERACTION
      PAGE RENDERING
ENTERPRISE INTEGRATION POINTS
TO THE RESCUE!
    (especially 1.1 and later)
THE GOOD STUFF
THE GOOD STUFF


  GrailsUnitTestCase
ControllerUnitTestCase
THE GOOD STUFF
THE GOOD STUFF

   mockDomain
  mockController
   mockLogging
   mockConfig
METACLASS MAGIC
mockDomain
mockDomain
  SUPPORTS
mockDomain
         SUPPORTS
   findAll()
findAllByXXX()
      get()
     read()
   getAll()
    ident()
   exists()
mockDomain
         SUPPORTS
   findAll()          count()
findAllByXXX()          list()
      get()         validate()
     read()           save()
   getAll()          delete()
    ident()         discard()
   exists()
mockDomain
mockDomain
DOES NOT SUPPORT
mockDomain
DOES NOT SUPPORT

      Criteria Builders
            HQL
Persistent Class Inheritance
        findWhere()
       findAllWhere()
mockController
mockController
    SUPPORTS
mockController
       SUPPORTS
    log
 request
response
 session
 params
   flash
mockController
       SUPPORTS
    log
                forward()
 request
                redirect()
response
                 render()
 session
              withFormat()
 params
               withForm()
   flash
mockController
mockController
    SUPPORTS
mockController
    SUPPORTS
    forwardArgs
    redirectArgs
     renderArgs
      template
   modelAndView
mockLogging
mockLogging

ADDS MOCKED LOG PROPERTY
mockLogging

ADDS MOCKED LOG PROPERTY
SENDS OUTPUT TO SYSTEM.OUT
mockLogging

     ADDS MOCKED LOG PROPERTY
    SENDS OUTPUT TO SYSTEM.OUT
IGNORES DEBUG AND TRACE BY DEFAULT
mockLogging

     ADDS MOCKED LOG PROPERTY
    SENDS OUTPUT TO SYSTEM.OUT
IGNORES DEBUG AND TRACE BY DEFAULT
  CAN ENABLE DEBUG WITH A SWITCH
mockConfig
mockConfig

REPLACES DEFAULT GRAILS CONFIG IN
      grailsApplication.config
mockConfig

REPLACES DEFAULT GRAILS CONFIG IN
      grailsApplication.config
      READS FROM A STRING
GrailsUnitTestCase
GrailsUnitTestCase
   INTRINSIC PROPERTIES
      applicationContext
      errorsMap
   INTRINSIC METHODS
      mockFor
      mockDomain
      mockController
      mockTagLib
      mockConfig
GrailsUnitTestCase


MUST CALL super.setUp()!
ControllerUnitTestCase
   INTRINSIC PROPERTIES
ControllerUnitTestCase
   INTRINSIC PROPERTIES
        mockRequest
        mockResponse
         mockSession
         forwardArgs
         redirectArgs
          renderArgs
         mockParams
          mockFlash
ControllerUnitTestCase
ControllerUnitTestCase


  AUTOMATICALLY MOCKS
CONTROLLER FROM TEST CLASS
          NAME
ControllerUnitTestCase



MUST CALL super.setUp()
LET’S USE THIS!
OUR APP


USER GROUP MEMBERSHIP
      MANAGER
STORIES


 AS AN UNREGISTERED USER, I
WANT TO SIGN UP ON THE SITE.
STORIES


AS A REGISTERED USER, I WANT TO
     SEE UPCOMING EVENTS.
STORIES

AS AN ADMINISTRATOR, I WANT
    TO HAVE FULL CRUD
 CAPABILITIES ON MEETINGS.
STORIES


AS AN ADMINISTRATOR, I WANT
TO SEE WHO IS ATTENDING AN
          EVENT.
STORIES


AS A REGISTERED USER, I WANT TO
 BE ABLE TO RSVP TO AN EVENT.
LIVE CODING!
THE CONCLUSION?
IT WORKS!
THERE ARE REAL
 LIMITATIONS
INTEGRATION AND
FUNCTIONAL TESTS
  ARE NECESSARY
CREDIBLE WEB APP
      TDD
THANK YOU!

TIM BERGLUND
AUGUST TECHNOLOGY GROUP, LLC
http://www.augusttechgroup.com
tim.berglund@augusttechgroup.com
@tlberglund
PHOTO CREDITS


SHIPPING CONTAINERS: HTTP://WWW.FLICKR.COM/PHOTOS/PHOTOHOME_UK/1494590209/
COMPUTER CONSOLE: HTTP://WWW.FLICKR.COM/PHOTOS/NOSTRI-IMAGO/2910549047/

More Related Content

What's hot

Unit tests in node.js
Unit tests in node.jsUnit tests in node.js
Unit tests in node.jsRotem Tamir
 
Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014alexandre freire
 
Testing JavaScript Applications
Testing JavaScript ApplicationsTesting JavaScript Applications
Testing JavaScript ApplicationsThe Rolling Scopes
 
PgTAP Best Practices
PgTAP Best PracticesPgTAP Best Practices
PgTAP Best PracticesDavid Wheeler
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsKonrad Malawski
 
JavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 ProxyJavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 ProxyAlexandr Skachkov
 
JAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineJAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineAnup Singh
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyIgor Napierala
 
Unit testing with mocha
Unit testing with mochaUnit testing with mocha
Unit testing with mochaRevath S Kumar
 
Fear no fragments
Fear no fragmentsFear no fragments
Fear no fragmentsDipo Areoye
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma Christopher Bartling
 
Testing javascript in the frontend
Testing javascript in the frontendTesting javascript in the frontend
Testing javascript in the frontendFrederic CABASSUT
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingLars Thorup
 
JSRs 303 and 330 in Action
JSRs 303 and 330 in ActionJSRs 303 and 330 in Action
JSRs 303 and 330 in Actionsimonetripodi
 
Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Roy Yu
 
Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18Brian Vermeer
 

What's hot (20)

Unit tests in node.js
Unit tests in node.jsUnit tests in node.js
Unit tests in node.js
 
Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014
 
Agile Android
Agile AndroidAgile Android
Agile Android
 
Testing JavaScript Applications
Testing JavaScript ApplicationsTesting JavaScript Applications
Testing JavaScript Applications
 
Agile Swift
Agile SwiftAgile Swift
Agile Swift
 
PgTAP Best Practices
PgTAP Best PracticesPgTAP Best Practices
PgTAP Best Practices
 
Jasmine BDD for Javascript
Jasmine BDD for JavascriptJasmine BDD for Javascript
Jasmine BDD for Javascript
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good Parts
 
JavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 ProxyJavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 Proxy
 
JAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineJAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & Jasmine
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishy
 
Unit testing with mocha
Unit testing with mochaUnit testing with mocha
Unit testing with mocha
 
Fear no fragments
Fear no fragmentsFear no fragments
Fear no fragments
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
 
Goto devoxx
Goto devoxxGoto devoxx
Goto devoxx
 
Testing javascript in the frontend
Testing javascript in the frontendTesting javascript in the frontend
Testing javascript in the frontend
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
 
JSRs 303 and 330 in Action
JSRs 303 and 330 in ActionJSRs 303 and 330 in Action
JSRs 303 and 330 in Action
 
Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101
 
Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18Java8 tgtbatu devoxxuk18
Java8 tgtbatu devoxxuk18
 

Viewers also liked

Kökler ve ekler
Kökler ve eklerKökler ve ekler
Kökler ve ekleryardimt
 
The rules of engagement how to avoid the brand wagon
The rules of engagement how to avoid the brand wagonThe rules of engagement how to avoid the brand wagon
The rules of engagement how to avoid the brand wagonDaniel Lipman
 
Tリック・サンダース / "去年の社会人一年生のRuby研修"
Tリック・サンダース / "去年の社会人一年生のRuby研修"Tリック・サンダース / "去年の社会人一年生のRuby研修"
Tリック・サンダース / "去年の社会人一年生のRuby研修"toRuby
 
Merita Citit a evoluat in favoarea ta
Merita Citit a evoluat in favoarea taMerita Citit a evoluat in favoarea ta
Merita Citit a evoluat in favoarea taCarla Alman
 
Présentation italie
Présentation italiePrésentation italie
Présentation italieEva Rekkedal
 
The Immutable Law of Social Media #REALationships WordCamp Miami 2016
The Immutable Law of Social Media #REALationships WordCamp Miami 2016The Immutable Law of Social Media #REALationships WordCamp Miami 2016
The Immutable Law of Social Media #REALationships WordCamp Miami 2016Gilbert Direct Marketing, Inc.
 
Higher Education on the Brink: Digitise or Disappear
Higher Education on the Brink: Digitise or DisappearHigher Education on the Brink: Digitise or Disappear
Higher Education on the Brink: Digitise or DisappearJeremy Williams
 
A Simple Direct Marketing Primer for Business Executives & Digital Marketers
A Simple Direct Marketing Primer for Business Executives & Digital MarketersA Simple Direct Marketing Primer for Business Executives & Digital Marketers
A Simple Direct Marketing Primer for Business Executives & Digital MarketersGilbert Direct Marketing, Inc.
 
Lauamangudest 170210 M Tapupere
Lauamangudest 170210 M TapupereLauamangudest 170210 M Tapupere
Lauamangudest 170210 M TapupereSirje Aher
 
French mystery geo
French mystery geoFrench mystery geo
French mystery geoEva Rekkedal
 
14 paragrafın anlatım yönü-anlatım teknikleri
14 paragrafın anlatım yönü-anlatım teknikleri14 paragrafın anlatım yönü-anlatım teknikleri
14 paragrafın anlatım yönü-anlatım teknikleriyardimt
 
CüMle Anlamy
CüMle AnlamyCüMle Anlamy
CüMle Anlamyyardimt
 
The Czech town mystery
The Czech town mysteryThe Czech town mystery
The Czech town mysteryEva Rekkedal
 
Comenius project semínka
Comenius project   semínkaComenius project   semínka
Comenius project semínkaEva Rekkedal
 

Viewers also liked (20)

Arun article1
Arun article1Arun article1
Arun article1
 
Kökler ve ekler
Kökler ve eklerKökler ve ekler
Kökler ve ekler
 
The rules of engagement how to avoid the brand wagon
The rules of engagement how to avoid the brand wagonThe rules of engagement how to avoid the brand wagon
The rules of engagement how to avoid the brand wagon
 
Tリック・サンダース / "去年の社会人一年生のRuby研修"
Tリック・サンダース / "去年の社会人一年生のRuby研修"Tリック・サンダース / "去年の社会人一年生のRuby研修"
Tリック・サンダース / "去年の社会人一年生のRuby研修"
 
Merita Citit a evoluat in favoarea ta
Merita Citit a evoluat in favoarea taMerita Citit a evoluat in favoarea ta
Merita Citit a evoluat in favoarea ta
 
Présentation italie
Présentation italiePrésentation italie
Présentation italie
 
The Immutable Law of Social Media #REALationships WordCamp Miami 2016
The Immutable Law of Social Media #REALationships WordCamp Miami 2016The Immutable Law of Social Media #REALationships WordCamp Miami 2016
The Immutable Law of Social Media #REALationships WordCamp Miami 2016
 
Isimler
IsimlerIsimler
Isimler
 
Higher Education on the Brink: Digitise or Disappear
Higher Education on the Brink: Digitise or DisappearHigher Education on the Brink: Digitise or Disappear
Higher Education on the Brink: Digitise or Disappear
 
A Simple Direct Marketing Primer for Business Executives & Digital Marketers
A Simple Direct Marketing Primer for Business Executives & Digital MarketersA Simple Direct Marketing Primer for Business Executives & Digital Marketers
A Simple Direct Marketing Primer for Business Executives & Digital Marketers
 
Jaws ug shimane-1
Jaws ug shimane-1Jaws ug shimane-1
Jaws ug shimane-1
 
Lauamangudest 170210 M Tapupere
Lauamangudest 170210 M TapupereLauamangudest 170210 M Tapupere
Lauamangudest 170210 M Tapupere
 
Kipler
KiplerKipler
Kipler
 
French mystery geo
French mystery geoFrench mystery geo
French mystery geo
 
14 paragrafın anlatım yönü-anlatım teknikleri
14 paragrafın anlatım yönü-anlatım teknikleri14 paragrafın anlatım yönü-anlatım teknikleri
14 paragrafın anlatım yönü-anlatım teknikleri
 
CüMle Anlamy
CüMle AnlamyCüMle Anlamy
CüMle Anlamy
 
The Czech town mystery
The Czech town mysteryThe Czech town mystery
The Czech town mystery
 
Comenius project semínka
Comenius project   semínkaComenius project   semínka
Comenius project semínka
 
February25 2010 Wcb Board Meeting Final For Web
February25 2010 Wcb Board Meeting Final For WebFebruary25 2010 Wcb Board Meeting Final For Web
February25 2010 Wcb Board Meeting Final For Web
 
Teaching Defense
Teaching DefenseTeaching Defense
Teaching Defense
 

Similar to Test First Refresh Second: Test-Driven Development in Grails

점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정Arawn Park
 
Troubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersTroubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersDocker, Inc.
 
Profiling distributed Java applications
Profiling distributed Java applicationsProfiling distributed Java applications
Profiling distributed Java applicationsConstantine Slisenka
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and ToolsBob Paulin
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneDroidConTLV
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinJava User Group Latvia
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignVictor Rentea
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...Guillaume Laforge
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVMJohn Lee
 
Programming proxies to do what we need so we don't have to talk to the networ...
Programming proxies to do what we need so we don't have to talk to the networ...Programming proxies to do what we need so we don't have to talk to the networ...
Programming proxies to do what we need so we don't have to talk to the networ...Lori MacVittie
 
Dropwizard Introduction
Dropwizard IntroductionDropwizard Introduction
Dropwizard IntroductionAnthony Chen
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthDanno Ferrin
 
Selenium-online-training
Selenium-online-trainingSelenium-online-training
Selenium-online-trainingRaghav Arora
 
如何建立企業級應用的商業規則引擎
如何建立企業級應用的商業規則引擎如何建立企業級應用的商業規則引擎
如何建立企業級應用的商業規則引擎CodeData
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web AppsFrank Kim
 
Continuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSContinuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSDanilo Poccia
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Matthew McCullough
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyonddion
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB
 

Similar to Test First Refresh Second: Test-Driven Development in Grails (20)

점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정점진적인 레거시 웹 애플리케이션 개선 과정
점진적인 레거시 웹 애플리케이션 개선 과정
 
Troubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersTroubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineers
 
Profiling distributed Java applications
Profiling distributed Java applicationsProfiling distributed Java applications
Profiling distributed Java applications
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and Tools
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVM
 
Programming proxies to do what we need so we don't have to talk to the networ...
Programming proxies to do what we need so we don't have to talk to the networ...Programming proxies to do what we need so we don't have to talk to the networ...
Programming proxies to do what we need so we don't have to talk to the networ...
 
Dropwizard Introduction
Dropwizard IntroductionDropwizard Introduction
Dropwizard Introduction
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In Depth
 
Selenium-online-training
Selenium-online-trainingSelenium-online-training
Selenium-online-training
 
如何建立企業級應用的商業規則引擎
如何建立企業級應用的商業規則引擎如何建立企業級應用的商業規則引擎
如何建立企業級應用的商業規則引擎
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web Apps
 
Continuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSContinuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWS
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyond
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 

More from Tim Berglund

Distributed Systems In One Lesson
Distributed Systems In One LessonDistributed Systems In One Lesson
Distributed Systems In One LessonTim Berglund
 
Decision Making in Software Teams
Decision Making in Software TeamsDecision Making in Software Teams
Decision Making in Software TeamsTim Berglund
 
Then our buildings shape us 10 minutes
Then our buildings shape us   10 minutesThen our buildings shape us   10 minutes
Then our buildings shape us 10 minutesTim Berglund
 
Complexity Theory and Software Development
Complexity Theory and Software DevelopmentComplexity Theory and Software Development
Complexity Theory and Software DevelopmentTim Berglund
 
Gaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineGaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineTim Berglund
 
Slaying The Legacy Dragon: Practical Lessons in Replacing Old Software
Slaying The Legacy Dragon: Practical Lessons in Replacing Old SoftwareSlaying The Legacy Dragon: Practical Lessons in Replacing Old Software
Slaying The Legacy Dragon: Practical Lessons in Replacing Old SoftwareTim Berglund
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTim Berglund
 
Agile Database Development with Liquibase
Agile Database Development with LiquibaseAgile Database Development with Liquibase
Agile Database Development with LiquibaseTim Berglund
 
Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With LiquibaseTim Berglund
 

More from Tim Berglund (10)

Distributed Systems In One Lesson
Distributed Systems In One LessonDistributed Systems In One Lesson
Distributed Systems In One Lesson
 
NoSQL Smackdown!
NoSQL Smackdown!NoSQL Smackdown!
NoSQL Smackdown!
 
Decision Making in Software Teams
Decision Making in Software TeamsDecision Making in Software Teams
Decision Making in Software Teams
 
Then our buildings shape us 10 minutes
Then our buildings shape us   10 minutesThen our buildings shape us   10 minutes
Then our buildings shape us 10 minutes
 
Complexity Theory and Software Development
Complexity Theory and Software DevelopmentComplexity Theory and Software Development
Complexity Theory and Software Development
 
Gaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineGaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App Engine
 
Slaying The Legacy Dragon: Practical Lessons in Replacing Old Software
Slaying The Legacy Dragon: Practical Lessons in Replacing Old SoftwareSlaying The Legacy Dragon: Practical Lessons in Replacing Old Software
Slaying The Legacy Dragon: Practical Lessons in Replacing Old Software
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in Grails
 
Agile Database Development with Liquibase
Agile Database Development with LiquibaseAgile Database Development with Liquibase
Agile Database Development with Liquibase
 
Database Refactoring With Liquibase
Database Refactoring With LiquibaseDatabase Refactoring With Liquibase
Database Refactoring With Liquibase
 

Recently uploaded

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Test First Refresh Second: Test-Driven Development in Grails

Editor's Notes

  1. Test-driven development has reached the status of received orthodoxy. For my part, I don’t object to the idea of a right way of thinking, but in our line of work, we should watch ourselves. There are some people critical of the idea of testing first, and we should listen to them.
  2. One way to gauge the health of our community is to see what happens to people who don’t toe the line. We don’t want to burn them at the stake. We should listen to them. It’s especially easy to eschew testing in difficult environments, and some people do so. We should ask why.
  3. Small pieces of code tested in isolation from each other. Typically at the class or method level. Often uses practices like stubbing and mocking to effect isolation. Runs fast, particularly if the IDE has a test runner that doesn’t require booting a new JVM or rebuilding the world.
  4. Small pieces of code tested in isolation from each other. Typically at the class or method level. Often uses practices like stubbing and mocking to effect isolation. Runs fast, particularly if the IDE has a test runner that doesn’t require booting a new JVM or rebuilding the world.
  5. Multiple units tested together in collaboration. Usually implies testing our code with a live database and servlet container. Want to test actual ORM, page rendering, service layer, etc. Runs slower. Not suitable for TDD. Should be run by a build server.
  6. Multiple units tested together in collaboration. Usually implies testing our code with a live database and servlet container. Want to test actual ORM, page rendering, service layer, etc. Runs slower. Not suitable for TDD. Should be run by a build server.
  7. Multiple units tested together in collaboration. Usually implies testing our code with a live database and servlet container. Want to test actual ORM, page rendering, service layer, etc. Runs slower. Not suitable for TDD. Should be run by a build server.
  8. Testing features of the fully assembled system. Best to do in a story-driven fashion. Certainly slow, requires significant server infrastructure (compared to JUnit), should be run by a build server.
  9. Testing features of the fully assembled system. Best to do in a story-driven fashion. Certainly slow, requires significant server infrastructure (compared to JUnit), should be run by a build server.
  10. Testing features of the fully assembled system. Best to do in a story-driven fashion. Certainly slow, requires significant server infrastructure (compared to JUnit), should be run by a build server.
  11. Our main concern tonight will be unit tests. You really can’t do TDD with integration or functional tests, because they take too long to run. There are two things that are important when considering unit tests.
  12. These are code, not human procedures.
  13. Each unit test should make assertions about a small, coherent chunk of code. Moreover, it should not matter in what order we run them. Each should be fully responsible for creating the state it needs to run its code under test.
  14. Since they are executable, we should be able to have a computer run them very frequently.
  15. Let’s talk about isolation some more. It’s easy—or can be—when you’re writing APIs in core Java. It’s hard in a web app. Why is that? (DB, servlet container, browser, HTTP loop)
  16. Besides the web and database problems, we usually have problems related to integration points, since
  17. Besides the web and database problems, we usually have problems related to integration points, since
  18. Besides the web and database problems, we usually have problems related to integration points, since
  19. Besides the web and database problems, we usually have problems related to integration points, since
  20. Besides the web and database problems, we usually have problems related to integration points, since
  21. The Testing plugin was made a part of core Grails as of the 1.1 release. It revolutionized the way we can test Grails apps.
  22. These are extensions to GroovyTestCase, which is itself an extension to JUnit’s TestCase.
  23. These four methods form the substance of the features provided by the two base testing classes. We’ll discuss their features in turn, then demonstrate some of them.
  24. At runtime, the simple domain, controller, service, job, and tag library classes you write in Groovy are modified significantly at the MetaClass level. This requires the Spring container to be booted, etc., all of which takes time. These test methods make direct modifications to the MetaClass of the classes under test to mock the desired behavior in a convincing way.
  25. findWhere() is coming in 1.2
  26. findWhere() is coming in 1.2
  27. As properties of the mocked class, and as properties of the test case class if extended from ControllerUnitTest
  28. As properties of the mocked class, and as properties of the test case class if extended from ControllerUnitTest
  29. Is automatically called by mockController
  30. Is automatically called by mockController
  31. Is automatically called by mockController
  32. Is automatically called by mockController
  33. Provides certain properties and method to the test case class.
  34. It does important things. If you override setUp() (and you probably should), remember to call this.
  35. These are all provided to the class under test automatically.
  36. This is a convenience feature. It does not mock relevant domain classes.
  37. Users have name, email, company title, membership status.
  38. Meetings have a start time, end time, location, description, member price, and nonmember price.
  39. As an
  40. As an
  41. It’s best to determine the shape of the testing framework and the functionality it covers, and try to write testable code on that basis. Usually that results in better factoring anyway.
  42. You’ll use criteria if you’re doing anything of any complexity.
  43. It’s economical to write tests this way, and enough of the framework is mocked to get the job done. You can actually write code against your domain model and controllers while testing first.