abstract · edit generated class test driving wher eÕs our state? was in the in-memory database...
TRANSCRIPT
![Page 1: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/1.jpg)
Agile Web Development
with Grailsspkr.name = 'Venkat Subramaniam'
spkr.company = 'Agile Developer, Inc.'
spkr.credentials = %w{Programmer Trainer Author}
spkr.blog = 'agiledeveloper.com/blog'
spkr.email = '[email protected]'
Abstract
Agile development is all about developing code and seeking feedback from your users to make sure you're developing what's relevant. When they suggest changes, those must be affordable and reliable. Grails, along with its facility to develop test driven, is a killer combination for rapidly developing web applications. In this ZePo (Zero PowerPoint) presentation, we will take a test driven approach to developing a small but fully functional web application in Grails. We will cover the fundamental features of Grails along with utilizing other capabilities like Ajax. At the end of this presentation, you will not only be confident, but eager to roll your own web application using Grails.
2
![Page 2: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/2.jpg)
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
3
What’s Grails?
Open Source Web Framework
Inspired by Rails, but not a port
Uses Groovy and Java
Built for JVM
Rapid Development of CRUD Applications
But you can leverage Java strengths
This presentation based on Grail 0.6
4
![Page 3: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/3.jpg)
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
5
Grails Principles
DRY
Convention Over Configuration
A bit of a problem when you’re new
Once you get used to it, you’re in Paradise
Keep it Simple
Leverage Java Platform
6
![Page 4: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/4.jpg)
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
7
Grails MVC
Grails built on concept of MVC
It does not merely recommend that you use MVC
It tells you to do so, then follows you home, and sits next to you to make sure you do
BROWSER
Model
Control
View
8
![Page 5: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/5.jpg)
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
9
Build and Learn
A Contacts Application
Add name, email, phone, state of residence
Edit, list, ...
10
![Page 6: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/6.jpg)
grails Generator
11
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
12
![Page 7: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/7.jpg)
Create App
13
Directory Structure
14
![Page 8: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/8.jpg)
Code Generation
Grails script generates quite a bit of stuff for you
Mostly html
Code is mostly synthesized rather than being generated
15
Three Configurations
16
Creates three configurations
Production
Development
Testing
![Page 9: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/9.jpg)
Create Domain class
17
Generated Code
18
![Page 10: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/10.jpg)
Editing Domain Class
19
Generating Controller and Views
20
![Page 11: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/11.jpg)
Controller
21
Views
22
![Page 12: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/12.jpg)
A Quick Test Drive
23
A Quick Test Drive...
Created New State by clicking on this link
24
![Page 13: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/13.jpg)
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
25
Test Driven DevelopmentA way to design an application
Helps find problems quickly
As system evolves, let us know if we meet the expectations
Serves as a valuable form of documentation
Safety net for refactoring
Write Positive, Negative, and Exception tests
In Grails 0.6, these are generated under Integration Tests (from a pure definition point of view, they are since you may talk to DB?)
26
![Page 14: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/14.jpg)
Test First Domain Logic
27
Code Next Domain Logic
28
![Page 15: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/15.jpg)
After Two More Tests...
29
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
30
![Page 16: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/16.jpg)
Integration Testing
Functional Testing or Integration Testing is automated testing of functionality
Very helpful when done in addition to unit testing
Grails uses Canoo for this
31
Generate Web Test
32
![Page 17: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/17.jpg)
Generated Web Test
33
Running Generated Tests
34
Got an error, so downloaded latest version of log4jand copied log4j-1.2.15.jar to grails install lib directory
![Page 18: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/18.jpg)
Viewing Test Results
35
Fixing the Test for Validation Error
36
![Page 19: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/19.jpg)
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
37
Building Second Domain Class
We will continue to build the next Domain class—Person
Steps similar to what we’ve done earlier
Create Domain Class
Generate Controller and Views
38
![Page 20: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/20.jpg)
Person Class
39
Edit generated class
Test Driving
Where’s our State?Was in the in-memory database
Missing State won’t give confidence to our customer40
![Page 21: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/21.jpg)
Bootstrap Data
41
Restart grails
???
42
![Page 22: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/22.jpg)
A Quick Fix
Add optionValue elementto the select element in create.gsp
43
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
44
![Page 23: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/23.jpg)
Templates
Reusable fragments
File naming convention starts with _
You can render as a bean or collection
bean results in one expansion
collection results in one expansion per element of collection
45
Templates
46
Content moved to _addperson.gsp and referred here
![Page 24: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/24.jpg)
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
47
Ajaxing Frameworks
Very easy to integrate with Ajax frameworks
Ships with Prototype
You may use other frameworks as well
48
![Page 25: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/25.jpg)
Ajaxing Create
49
list.gsp
Ajaxing Create...
50
![Page 26: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/26.jpg)
Ajaxing Create...
51
Ajaxing Create...
52
![Page 27: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/27.jpg)
Ajaxing Create...
53
Agenda
What’s Grails?
Principles
Fundamentals
A Quick App
Phase I
Unit Testing
Functional Testing
Phase II
Templatizing
Ajaxing
Conclusion
54
![Page 28: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/28.jpg)
Quiz Time
55
Referenceshttp://grails.codehaus.org
http://grails.codehaus.org/Download
http://groovy.codehaus.org
http://groovy.codehaus.org/Download
http://aboutgroovy.com
56
![Page 29: Abstract · Edit generated class Test Driving Wher eÕs our State? Was in the in-memory database Missing State wonÕt give conÞdence to our customer 40 Bootstrap Data 41 Restar t](https://reader035.vdocument.in/reader035/viewer/2022071113/5fea5c2bcc472c66c03e0bf8/html5/thumbnails/29.jpg)
Thank You!
http://www.agiledeveloper.com — download
57