Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

London Selenium Meetup: ATDD with Behat

London Selenium Meetup: ATDD with Behat

Behat is a BDD tool for PHP application. This talk explained Behat Mink, Composer and stuff
Meetup Link : http://www.meetup.com/seleniumlondon/events/61732192/

Links to Video: http://bitly.com/bundles/undeleterious/1

Shashikant Jagtap

June 29, 2012
Tweet

More Decks by Shashikant Jagtap

Other Decks in Technology

Transcript

  1. About M e Shas hi kant J agt ap [

    Shas hi ] Twi t t er : @ Shas hi kant 86 London Behat Us er s [ #LDNBU] BDD Ent hus i as t i c Tes t er
  2. Over vi ew ATDD Behat f r om Scr at

    ch Com pos er & M i nk Ext ens i on
  3. Over vi ew ATDD Behat f r om Scr at

    ch Com pos er & M i nkExt ens i on Speedi ng up BDD wi t h Subl i m e Text 2 Br ows er Aut om at i on wi t h Sel eni um ATDD wi t h Behat and Sel eni um ANT & HTM L Repor t Gener at i on Vi deo/Li ve Dem o
  4. ATDD Accept ance Tes t Dr i ven Devel opm

    ent Discuss Stor y 2 Stor y 1 Stor y 3
  5. ATDD Accept ance Tes t Dr i ven Devel opm

    ent Dis c us s Stor y 2 Stor y 1 Stor y 3 Specification Workshop Dis till Tester Develope rs PM/S M
  6. ATDD Accept ance Tes t Dr i ven Devel opm

    ent Dis c us s Stor y 2 Stor y 1 Stor y 3 Specification Workshop Dis till Tester Develope rs PM/S M Implement Acceptance Tests Test er Devel oper
  7. ATDD Accept ance Tes t Dr i ven Devel opm

    ent Dis c us s Stor y 2 Stor y 1 Stor y 3 Specification Workshop Dis till Tester Develope rs PM/S M Implement Acceptance Tests Test er Devel oper Demo Executable Spec Automat ion Automat ion
  8. ATDD Get Accept ance Cr i t er i a

    W r i t e Accept ance Tes t Col l abor at i vel y [ Fai l i ng/Undef i ned]
  9. ATDD Get Accept ance Cr i t er i a

    W r i t e Accept ance Tes t Col l abor at i vel y [ Fai l i ng/Undef i ned] I m pl em ent St ep Def i ni t i on t o m ake i t Pas s
  10. ATDD Get Accept ance Cr i t er i a

    W r i t e Accept ance Tes t Col l abor at i vel y [ Fai l i ng/Undef i ned] I m pl em ent St ep Def i ni t i on t o m ake i t Pas s Tes t Pas s ! ! Aut om at i on Achi eved.
  11. Behat Behat i s a BDD t ool f or

    PHP Appl i cat i ons ht t p: //behat . or g/ M i nk i s a web Accept ance Tes t i ng Fr am ewor k f or PHP ht t p: //m i nk. behat . or g/ Com bi nat i on of Behat /M i nk can be us ed f or web accept ance Tes t i ng. M i nk has Sel eni um 1 & Sel eni um 2 Dr i ver s f or br ows er aut om at i on
  12. W ho i s Doi ng/M ai nt ai ni

    ng? Kons t ant i n Kudr yas hov - Knpl abs , Fr ance Twi t t er : @ ever zet Gi t Hub : Ever zet + Som e Awes om e Cont r i but or s
  13. Let ' s Get St ar t ed W i

    t h Behat Pr e- r equi s i t e Lapt op/Com put er PHP St acks ( LAM P, W AM P, M AM P) Sel eni um Ser ver Cur l or wget Gi t Hub ( opt i onal )
  14. I f Not Then $ pear channel - di s

    cover pear . s ym f ony. com $ pear channel - di s cover pear . behat . or g $ pear i ns t al l behat /behat pear i ns t al l behat /m i nk
  15. I f Not Then $ pear channel - di s

    cover pear . s ym f ony. com $ pear channel - di s cover pear . behat . or g $ pear i ns t al l behat /behat pear i ns t al l behat /m i nk You Ready t o us e Behat /M i nk,
  16. I f Not Then $ pear channel - di s

    cover pear . s ym f ony. com $ pear channel - di s cover pear . behat . or g $ pear i ns t al l behat /behat pear i ns t al l behat /m i nk You Ready t o us e Behat /M i nk, W AI T. . . . W e got EASI ER OPTI ON ! ! ! ! !
  17. W e Got Com pos er ! ! ! !

    ! ! Com pos er i s dependency m anager f or PHP Com pos er al l ow you t o decl ar e l i br ar i es you needed and i ns t al l i t f or you J us t def i ne al l dependenci es i n ' com pos er . j s on' f i l e and you ar e done ! ! So, Let ' s do t hat
  18. Cr eat e Pr oj ect M ake New Di

    r ect or y $ m kdi r Behat Dem o $ cd Behat Dem o
  19. Cr eat e compos er . j s on {

    "r equi r e": { "behat /behat ": "2. 4@ s t abl e", "behat /m i nk- ext ens i on": "dev- m as t er ", "f abpot /gout t e": "*", "al exandr es al om e/php- s el eni um ": "*", "i ns t acl i ck/php- webdr i ver ": "*" } , "conf i g": { "bi n- di r ": "bi n" } }
  20. Cr eat e ' behat . yml ' d e

    f a ul t : c o n t e x t : c l a s s : ' Fe a t ur e Co n t e x t ' e x t e n s i o n s : B e h a t \ M i n k Ex t e n s i o n \ Ex t e n s i o n : b a s e _ur l : ' h t t p : / / s a uc e l a b s . c o m/ ' j a v a s c r i p t _s e s s i o n : ' s e l e n i um2 ' g o ut t e : ~ s e l e n i um2 :
  21. Downl oad Com pos er D o wn l o

    a d c o mp o s e r us i n g c o mma n d $cur l ht t p: //get com pos er . or g/i ns t al l er | php
  22. Downl oad Com pos er D o wn l o

    a d c o mp o s e r us i n g c o mma n d $cur l ht t p: //get com pos er . or g/i ns t al l er | php Sh a s h i - M a c B o o k - Pr o : B e h a t D e mo us e r $ c ur l h t t p : / / g e t c o mp o s e r . o r g / i n s t a l l e r | p h p % To t a l % R e c e i v e d % X f e r d A v e r a g e Sp e e d Ti me Ti me Ti me Cur r e n t D l o a d U p l o a d To t a l Sp e n t Le f t Sp e e d 1 0 0 7 6 0 6 1 0 0 7 6 0 6 0 0 5 9 6 3 6 0 - - : - - : - - - - : - - : - - - - : - - : - - 1 6 5 k #! / us r / b i n / e n v p h p A l l s e t t i n g s c o r r e c t f o r us i n g Co mp o s e r D o wn l o a d i n g . . .
  23. I ns t al l com pos er . phar

    $ p h p c o mp o s e r . p h a r i n s t a l l Yo u c a n a l s o us e $ p h p c o mp o s e r . p h a r up d a t e
  24. I ns t al l com pos er . phar

    $ p h p c o mp o s e r . p h a r i n s t a l l Sh a s h i - M a c B o o k - Pr o : B e h a t D e mo us e r $ p h p c o mp o s e r . p h a r up d a t e U p d a t i n g d e p e n d e n c i e s - In s t a l l i n g g uz z l e / g uz z l e ( v 2 . 6 . 3 ) D o wn l o a d i n g : 1 0 0 % - In s t a l l i n g s y mf o n y / y a ml ( d e v - ma s t e r ) Cl o n i n g 4 9 a d 5 0 0 4 4 8 c 1 7 a 4 b 5 1 5 c 8 f 5 6 7 d b b 5 4 0 a f 3 c f 4 1 e f - In s t a l l i n g s y mf o n y / t r a n s l a t i o n ( d e v - ma s t e r ) [ So o n … . . . . . . . . . . . ]
  25. St ar t Behat $ . /bi n/behat - -

    i ni t Sh a s h i - M a c B o o k - Pr o : B e h a t D e mo us e r $ . / b i n / b e h a t - - i n i t +d f e a t ur e s - p l a c e y o ur * . f e a t ur e f i l e s h e r e +d f e a t ur e s / b o o t s t r a p - p l a c e b o o t s t r a p s c r i p t s a n d s t a t i c f i l e s h e r e +f f e a t ur e s / b o o t s t r a p / Fe a t ur e Co n t e x t . p h p - p l a c e y o ur f e a t ur e r e l a t e d c o d e h e r e [ You wi l l See Behat cr eat ed ' f eat ur es ' and ' boot s t r ap' di r ect or y f or you]
  26. Behat Di d Somet hi ng ? Cr e a

    t e d ' f e a t ur e s ' d i r e c t o r y Cr e a t e d ' b o o t s t r a p ' d i r e c t o r y a n d ' Fe a t ur e Co n t e x t . p h p ' f i l e wh e r e we wi l l i mp l e me n t s t e p d e f i n i t i o n s .
  27. M i nk Ext ens i on W e need

    ' Feat ur eCont ext ' cl as s t o' Behat \M i nkExt ens i on\Cont ext \M i n kCont ext So, W e ar e us i ng ' M i nkExt ens i on' whi ch aut om at i cal l y cr eat e M i nk i ns t ance. W e us ed M i nk API ' s t o aut om at ed Br ows er act i ons . ( ht t p: //m i nk. behat . or g/api /)
  28. N o w, W e a r e r e

    a d y t o us e B e h a t , M i n k , Se l e n i um a n d s t uf f . R un B e h a t wi t h $ . /bi n/behat
  29. How i t Looks Li ke? Feat ur e: f

    eat ur e I n or der t o [ add f eat ur e] As a [ r ol e] I want [ f eat ut e] Scenar i o: Fi r s t Scenar i o Gi ven [ Cont ext ] W hen [ Act i on] Then [ Out Com e]
  30. Bl ogSear ch. f eat ur e Feature: Blog Search

    I n or der t o s ear ch bl ogs As a s auce us er I need s ee bl ogs @ j avas cr i pt Scenario: Search Behat Blogs Given I am on "/blog" When I fill in "s" with "behat" And I press "Search" Then I should see "Adding Sauce To Behat" [ Th i s f i l e s h o ul d b e i n / f e a t ur e s d i r e c t o r y . ]
  31. W hat wi l l Hel p t o wr

    i t e f eat ur e? Behat Cheat Sheet ht t p: //bl og. l epi ne. pr o/php/r es s our ces - M i nk Api ' s ht t p: //m i nk. behat . or g/api /
  32. I know, Too Bor i ng t o t ype

    ? Let M e Show You Som et hi ng W hi ch W i l l do t hi s i n a M i nut e
  33. Subl i m e Text 2 : Behat - M

    i nk Sni ppet s .
  34. W ho W r ot e Awes om e Sni

    ppet s W i l l em s en Chr i s t ophe Gi t Hub : kwat t r o - I nt r anet appz devel oper f or t he Bel gi an Def ens e, BDD pr act i t i oner . [ Sym f ony] Twi t t er : @ i kwat t r o Gi t Hub: ht t ps : //gi t hub. com /kwat t r o/s ubl i m e - behat - s ni ppet s
  35. Don' t f or get To t ag Scenar i

    os wi t h “@ j avas cr i pt ” t ag & Launch our Lovel y Sel eni um Ser ver $ j ava - j ar s el eni um - s er ver - s t andal one- 2. 21. 0. j ar
  36. Now Run $. /bi n/behat W at ch Tes t

    Runni ng i n a Br ows er
  37. ATDD wi t h Behat & Sel eni um How

    s houl d I f i nd l ocat or s bef or e I m pl em ent at i on?
  38. ATDD wi t h Behat & Sel eni um How

    s houl d I f i nd l ocat or s bef or e I m pl em ent at i on? Don' t wor r y, W r i t e hi gh l evel t es t s and Behat & M i nk API ' s wi l l hel p you t o i m pl em ent St ep def l at er ( af t er i m pl em ent at i on)
  39. at dd. f eat ur e Feat ur e: ATDD

    I n or der t o i m pl em ent ATDD As a QA I need t o wr i t e accept ance t es t s f i r s t @ j avas cr i pt @ at dd Scenar i o: Sear chi ng Gi ven I am on bl ogs page W hen I s ear ch f or "c h i p s " Then I s houl d s ee "N o Po s t s "
  40. I mpl em ent St eps / * * *

    @W h e n / ^I s e a r c h f o r " ( [ ^" ] * ) " $ / * / publ i c f unct i on i Sear chFor ( $ k e y ) { $ t h i s - >f i l l Fi e l d ( " s " , $ k e y ) ; $ t h i s - >p r e s s B ut t o n ( " Se a r c h " ) ; } / * * * @G i v e n / ^I a m o n b l o g s p a g e $ / * / publ i c f unct i on i Am OnBl ogs Page( ) { $ t h i s - >v i s i t ( " / b l o g " ) ; }
  41. Run Scenar i os wi t h ' at dd'

    t ags $ . /bi n/behat - - t ags ="at dd"
  42. Gener at e Repor t To Gener at e HTM

    L r epor t s $ . /bi n/behat - f ht m l - - out r epor t . ht m l You wi l l s ee ' r epor t . ht m l ' gener at ed whi ch l ooks awes om e i n br ows er ! !
  43. Get Code $git clone [email protected]:Shashikant86/BehatDemo.git $cd BehatDemo $curl http://getcomposer.org/installer |

    php $php composer.phar install Download Selenium Server and launch server $ java -jar selenium-server-standalone-2.21.0.jar $./bin/behat
  44. Run ANT bui l d Shashi-MacBook-Pro:BehatDemo user$ ant run Buildfile:

    /Users/user/BehatDemo/build.xml run: [delete] Deleting directory /Users/user/BehatDemo/report [mkdir] Created dir: /Users/user/BehatDemo/report behat: BUILD SUCCESSFUL Total time: 21 seconds
  45. Repor t s W e h a v e c

    r e a t e d ' r e p o r t ' d i r e c t o r y t o s a v e t e s t r e p o r t o f t h e l a t e s t b ui l d R e p o r t wi l l g e n e r a t e i n h t ml f o r ma t i n t h e ' r e p o r t / r e p o r t . h t ml ' f i l e .
  46. Vi deo Demo How To cl one Repo and us

    e ht t p: //yout u. be/Apt - 1_94zCE Thi ngs W e di d ht t p: //t i nyur l . com /d79s 4oy
  47. Li nks h t t p: / / b e

    h a t . o r g / h t t p: / / mi n k . b e h a t . o r g / h t t ps : / / g i t h ub . c o m/ Sh a s h i k a n t 8 6 / B e h a t D e mo h t t ps : / / g i t h ub . c o m/ k wa t t r o / s ub l i me - b e h a t - s n i ppe t s h t t p: / / e v e r z e t . c o m/