SlideShare une entreprise Scribd logo
1  sur  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/

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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.pdfhans926745
 
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)wesley chun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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 WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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 FresherRemote DBA Services
 
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 WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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...Drew Madelung
 
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 AutomationSafe Software
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Dernier (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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...
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Test First Refresh Second: Test-Driven Development in Grails

Notes de l'éditeur

  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.