Test Context Arrangement Recipebook
Upcoming SlideShare
Loading in...5
×
 

Test Context Arrangement Recipebook

on

  • 6,749 views

 

Statistics

Views

Total Views
6,749
Views on SlideShare
5,106
Embed Views
1,643

Actions

Likes
11
Downloads
54
Comments
0

10 Embeds 1,643

http://d.hatena.ne.jp 1555
http://coderwall.com 49
http://ruby.agile.esm.co.jp 15
http://tweetedtimes.com 10
http://paper.li 5
http://twitter.com 4
https://twitter.com 2
http://www.slideshare.net 1
http://b.hatena.ne.jp 1
http://localhost 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Test Context Arrangement Recipebook Test Context Arrangement Recipebook Presentation Transcript

  • 5 years know-how ofRSpec drivenRails app.development MOROHASHI Kyosuke (@moro)
  • Kyosuke MOROHASHI✓ http://twitter.com/moro✓ http://github.com/moro✓ Eiwa System Management, Inc.
  • http://gihyo.jp/news/report/01/rubykaigi2011/0001
  • aigi byK rice Ru l p cia off spe % 40http://tatsu-zine.com/books/cuke
  • able o vail -D A Ju nku igi @ yKa Rubhttp://amzn.to/rails3recipebook
  • http://www.junkudo.co.jp/tenpo/evtalk.html#20110721ikebukuro
  • 5 years know-how ofRSpec drivenRails app.development MOROHASHI Kyosuke (@moro)
  • Test ContextArrangement 3
  • I’ll talk about.✓What test should I write first? ✓ Write model unit test.✓I began model test,but it’s difficult to setup data!! ✓ Use multi strategies for multi types of data.✓It seems good but less DRY. Is there any idea? ✓ Share your testing context.
  • m le obPr What test should I write first?
  • on ti luSo Write Model unit test.
  • People saySkinny Controllers Fat Models
  • It’s clear what happening.http://flic.kr/p/5tk4by
  • #64 2011-07-18 12:00 http://twitter.com/railstokyo
  • aigi byK rice Ru l p cia off spe % 40 Use Cucumber (or other end-to-end testing) to cover controller, views and more.http://tatsu-zine.com/books/cuke
  • Model unit test
  • m le obPr Began model test, but it’s difficult to setup data!!
  • events studentscourses lessons registrations rooms periods
  • Course-1 Course-2Period-1 Lesson-1-1 Lesson-2-1Period-2 Lesson-1-2 Lesson-2-2Period-3 Lesson-1-3 Lesson-2-3Period-4 Lesson-1-4 Lesson-2-4Period-5 Lesson-1-5 Lesson-2-5 registration
  • Course-1 Course-2Period-1 Lesson-1-1 Lesson-2-1Period-2 Lesson-1-2 Lesson-2-2Period-3 Lesson-1-3 Lesson-2-3Period-4 Lesson-1-4 Lesson-2-4Period-5 Lesson-1-5 Lesson-2-5 registration
  • Course-1 Course-2Period-1 Lesson-1-1 Lesson-2-1Period-2 Lesson-1-2 Lesson-2-2Period-3 Lesson-1-3 Lesson-2-3Period-4 Lesson-1-4 Lesson-2-4Period-5 Lesson-1-5 Lesson-2-5 registration
  • on ti lu Use multiSo strategies for multi types of data.
  • ✓ 3 types of data✓ 3 strategies
  • ✓ 3 types of data✓ 3 strategies
  • ✓ Master data✓ Resource data✓ Event data
  • Mastar data✓ Created/updated rarely. ✓e.g. rooms / periods.✓ Less dependencies to others.✓ Maintained by or so.
  • Resource data✓ Mainly created/updated data.✓ Users themselves maintains this type of data.
  • Event data✓ Represent relationship between resources.✓ Used for ‘s through table in Rails.
  • ✓ 3 types of data✓ 3 strategies
  • ✓ Fixture✓ Fixture replacement✓ block
  • Fixturehttp://flic.kr/p/5NfjKM
  • ✓ good speed to be loaded.✓ less maintainability.✓ less flexibility.
  • Fixture Replacementhttp://fabricationgem.org/
  • ✓ flexible.✓ powerful but difficult to use correctly.✓ slow to be loaded.
  • Which should we userails-fixture or fixturereplacement?Use them both whichsuitable for the data.
  • block
  • ✓ each run per test.✓ same speed with real data persistence.✓ edit each of them to maintain.
  • flexibility maintain- speed in test ability good for Master fixture best wrong wrong data fixture Resource wrong good bestreplacements data good for each Event before() good best wrong for all data
  • events students Resourcecourses lessons registrations Event rooms periods Master
  • on ti lu Use multiSo strategies for multi types of data.
  • ✓ fixture✓ fixture replacement✓ blockUse them all whichsuitable for the data.
  • m le It seems good obPr but less DRY. Is there any idea?
  • Students Course CountPeriod-1 Lesson-1-1 2Period-2 Lesson-1-2 3Period-3 Lesson-1-3 3Period-4 Lesson-1-4 3Period-5 Lesson-1-5 2
  • on ti luSo Share your testing context.
  • https://github.com/rspec
  • ✓ naming each✓ naming them
  • ✓ naming each✓ naming them
  • “Generates a method whosereturn value is memoizedafter the first call.
  • ✓ name each focusing object.✓ Build strategy doesn’t matter.
  • ✓ naming each✓ naming them
  • ✓ RSpec’s✓✓
  • A student subscribes a course event lesson-1-1 lesson-1-1course-1 lesson-1-1 lesson-1-1 lesson-1-1 registrations registrations registrations registrations Alice <student> room-1 room-1 period-1 period-1 room-1 room-1 period-1 period-1 room-1 period-1 course-2 lesson-2-1 lesson-2-1 lesson-2-1 lesson-2-1 lesson-2-1
  • ✓ naming each w/✓ naming them w/Express your intentionclearly and reducetiredness to add new test.
  • on ti luSo Share your testing context.
  • Conclusion
  • I’ve talked about.✓What test should I write first? ✓ Write model unit test.✓I began model test,but it’s difficult to setup data!! ✓ Use multi strategies for multi types of data.✓It seems good but less DRY. Is there any idea? ✓ Share your testing context.
  • ✓ fixture✓ fixture replacement✓ blockUse them all whichsuitable for the data.
  • ✓ naming each w/✓ naming them w/Express your intentionclearly and reducetiredness to add new test.
  • May a testbe with you.
  • http://www.rubyworld-conf.org/
  • May a testbe with you.