Upgrade to Pro — share decks privately, control downloads, hide ads and more …

cucumber-maochao

Mao Chao
October 10, 2015

 cucumber-maochao

2015 rubyconf china maochao presentation

Mao Chao

October 10, 2015
Tweet

Other Decks in Technology

Transcript

  1. R u b y C o n f C h i n a 2 0 1 5
    ᯯᯯމ੝ଙѺ
    CUCUMBERӧᚆᦏ֦፥ྋBDD
    ྷ᩻

    View full-size slide

  2. ᛔ౯Օᕨ
    ྷ ᩻
    ThoughtWorks Rubist
    CoCጱᇰᅾᆽঅᘏ
    ݸᒒ > ڹᒒ > Mobile

    View full-size slide

  3. Cucumber
    ᓌՕ

    View full-size slide

  4. አ ᕍ ෈ ๜ ൈ ᬿ ᤈ ԅ አ R u b y ਫ ሿ s t e p ᬩ ᤈ ଚ Ӭ ஑ ک Კ ᧏
    ᖫ ٟ դ Ꮁ ֵ s t e p ᭗ ᬦ ᬩ ᤈ ଚ ᥡ ੊ s t e p ᭗ ᬦ ᯿ ॔ a ྍ ፗ ک ق ᮱ ᭗ ᬦ

    View full-size slide

  5. Cucumber
    ሿᇫ

    View full-size slide

  6. ӨBDD୩ፘى

    View full-size slide

  7. ᨕྈ᩽۠
    B D D
    C u c u m b e r

    View full-size slide

  8. ASLAKጱݺབ
    ࣁ B D D ڊ ሿ ጱ ଙ ݸ ҅ ׁ ᆐ ํ ӧ ੝
    ࢫ ᴚ ࣁ ֵ አ B D D ෸ ڊ ሿ ᳯ ᷌ ŏ ŏ
    B D D ׁ ᆐ ᕪ ଉ ᤩ Ո ᧏ ᥴ ౮ ܔ ᕍ ጱ ၥ
    ᦶ ҅ ౲ ᘏ ฎ Ӟ ӻ ݢ զ ᤩ ӥ ᫹ ጱ ૡ ٍ
    ŏ ŏ ੪ ࣁ ๋ ᬪ ҅ C u c u m b e r ૪ ᕪ ᤩ
    ӥ ᫹ ԧ ᩻ ᬦ ӡ ེ ҅ ౯ உ ṛ ي ਙ
    ই ྌ ݑ ཻ ᬨ ҅ ݶ ෸ Ԟ ԅ ਙ ᤩ ଠ ာ ጱ
    ᧏ አ ᘒ ఽ ک ० ๕ ŏ ŏ ਙ ํ ෸ ׁ ᆐ ᤩ
    Კ ᧏ ጱ ୮ ౮ ԧ ᛔ ۖ ۸ ၥ ᦶ ૡ ٍ ҅ ᘒ
    ӧ ฎ ౯ ୮ ෸ ڠ ୌ ጱ ӳ ᥜ ̶
    A s l a k H e l l e s ø y,
    C u c u m b e r ֢ ᘏ

    View full-size slide

  9. ᮎԍᳯ᷌๶ԧ
    አC u c u m b e r੪
    ᚆBDDᐟۑಷ֛
    ԧҘ

    View full-size slide

  10. DAN
    NORTH
    BDD ORIGINATOR

    View full-size slide

  11. ଙጱᒫӞ࣋ᵪ

    View full-size slide

  12. ଙጱᒫӞ࣋ᵪ
    CustomerLookup
    - finds customer by id
    - fails for duplicate customers
    ……
    ෈ਁݒ۸

    View full-size slide

  13. ᭑ྍᄍᬰ
    TDD դᎱ
    ᤈԅ
    ᫫կ
    ᤈԅ
    BDD

    View full-size slide

  14. DANጱਧԎ
    B D D ฎ ᒫ ԫ դ ጱ ̵ ኧ क़ ݊ ٖ
    ጱ ̵ च ԭ ೉ p u l l ጱ ̵ ग़ ො
    ڥ ፅ ፘ ى ᘏ ጱ
    s t a k e h o l d e r ̵ ग़ ᐿ ݢ ಘ
    ઀ ጱ ̵ ṛ ᛔ ۖ ۸ ጱ භ ഠ ො ဩ ̶
    ਙ ൈ ᬿ ԧ Ӟ ӻ Ի ԰ ஗ ሾ ҅ ݢ
    զ ٍ ํ ଃ ํ ᜉ অ ਧ Ԏ ጱ ᬌ ڊ
    ҁ ܨ ૡ ֢ Ӿ Ի ՞ ጱ ᕮ ຎ ҂ ғ
    ૪ ၥ ᦶ ᬦ ጱ ᫫ կ ̶
    D a n N o r t h ,
    B D D ݎ ก Ո

    View full-size slide

  15. MATT ጱਧԎ
    B D D ጱ ਫ ᪢ ᘏ ժ ᭗ ᬦ ဋ ᭗
    Ի ၞ ҅ ٍ ֛ ጱ ᐏ ֺ ޾ ᛔ ۖ
    ۸ ၥ ᦶ ଆ ۗ ՜ ժ ๅ অ ࣈ റ
    ᔱ ҅ ݎ ሿ ҅ ਧ Ԏ ଚ ḝ ۖ ڊ
    Ո ժ ፥ ྋ మ አ ጱ ᫫ կ ̶
    M a t t W y n n e
    C u c u m b e r ֢ ᘏ

    View full-size slide

  16. ୩᧣ဋ᭗

    View full-size slide

  17. DISCOVERY
    WORKSHOP
    GENERATE
    EXAMPLES
    DRIVEN
    DEVELOPMENT
    Cucumberຽٵၞᑕ

    View full-size slide

  18. ፥ྋጱᑃᦣ

    View full-size slide

  19. ቘమஉӿჿ
    ሿਫஉṋఽ

    View full-size slide

  20. ӧىဳӱۓ
    Scenario: Detect agent type based on contract number


    Given I am on the 'Find me' page

    And I have entered a contract number

    When I click 'Continue' button

    And a contact number match is found

    Then the "Back" button will be displayed

    View full-size slide

  21. ਖኻ҅ᬮӧሿڊܻ୵

    View full-size slide

  22. ᯿॔ጱStep
    # A feature
    Given there is student Harry

    And there is professor Snape

    And student Harry joins class of professor Snape
    # B feature, use 1 new step instead of 3
    Given student Harry in class of professor Snape

    View full-size slide

  23. Step્ॺ᧣አ
    # ֵአVWHSොဩ᧣አ૪ᕪਂࣁጱVWHS

    Given /^student (.*) in class of professor (.*)/ do |stu, pro|

    step "there is student #{stu}"

    step "there is professor #{pro}"

    step "student #{stu} joins class of professor #{pro}"

    end
    Given /^there is student (.*)/ do |student|
    user = User.create(student)
    ……
    end
    Given /^there is student come from (.*)/ do |country|
    ……
    end

    View full-size slide

  24. ॰ওጱྋڞ
    ሖሖӥᶎጱྋڞࣁ܃ᯈՋԍҘ
    /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|
    [1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]
    {1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}
    [0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|
    [1-9]{1}[0-9]{1}|[0-9])$/

    View full-size slide

  25. ၚ෈໩
    փ᭓ӱۓ
    ၾᴻወజ
    ᕹӞᦊᦩ

    View full-size slide

  26. Reportݢ᧛௔૧
    ᬯ ฎ ੰ ሸ
    ၚ ෈ ໩

    View full-size slide

  27. ۱රӧ۱տ
    ᜉ ᬜ ๕ ֦
    ӣ ௏ ᘒ ݸ ᤈ




    View full-size slide

  28. ᵙ ᭲ C u c u m b e r
    ፥ ጱ ӧ অ አ Ҙ

    View full-size slide

  29. ىဳӱۓ
    Scenario: Detect agent type based on contract number

    Given I am on the 'Find me' page

    And I have entered a contract number

    When I click 'Continue' button

    And a contact number match is found

    Then the "Back" button will be displayed
    Scenario: Detect agent type based on contract number

    Given I have a "TiedAgent" policy

    When I submit my contract number

    Then I should be asked for my last name

    View full-size slide

  30. ᯿຅StepਫሿդᎱ

    Given /^there is student (.*)/ do |student|

    ModelFactory.create_user(student)

    end
    Given /^there is student (.*)/ do |student|
    user = User.create(student)
    ……
    end

    View full-size slide

  31. ᯿አStepਫሿդᎱ
    Given /^student (.*) in class of professor (.*)/ do |student,
    professor|

    ModelFactory.create_user(student, professor)

    ModelFactory.join_class(student, professor)

    end
    Given /^student (.*) in class of professor (.*)/ do |stu, pro|

    step "there is student #{stu}"

    step "there is professor #{pro}"

    step "student #{stu} joins class of professor #{pro}"

    end

    View full-size slide

  32. ಘ઀Cucumber
    @active-doc

    Scenario: Detect agent type based on
    contract number

    Given I have a "TiedAgent" policy

    When I submit my contract number

    Then I should be asked for my last name

    View full-size slide

  33. Ⴒےൈᬿ෈կ
    =====================
    Given I have a "TiedAgent" policy
    =====================
    ##Detail Information**
    **In this step, you are assigned
    a "TieAgent" policy.**
    ![screenshot-1](./i-have-a-tied-agent-policy.png)
    You can click [here](http://example.com)
    for more information
    =====================
    @active-doc

    Scenario: Detect agent type
    based on contract number

    Given I have a "TiedAgent"
    policy

    When I submit my contract
    number

    Then I should be asked for
    my last name

    View full-size slide

  34. ኞ౮෈໩
    ᦕ୯VWHS
    ᬰᤈ౼ࢶ
    ᘉᦲ0'
    ᬰᤈ೪ᤰ
    Cucumber ActiveDoc HTML

    View full-size slide

  35. ᫨᥯᭬کᆽ

    View full-size slide

  36. &XFXPEHU
    Ӥಋᓌܔ҅ᐒ܄ၚ᪋
    ෈໩ᤒሿێӧ᪃
    ඪ೮ռग़ଘݣ

    View full-size slide

  37. &RQFRUGLRQ
    HTML෈໩҅ᤒሿێ୩
    ṛݢਧګ۸෈໩
    HTML਍ԟ౮๜ṛ
    ݝඪ೮Java޾C#

    View full-size slide

  38. Gauge
    Markdown໒ୗ෈໩
    ۑᚆӧਠ࠺
    Golang୏ݎ҅௔ᚆ᫾অ

    View full-size slide

  39. ௛ᕮӞӥ
    %''୩᧣ၞᑕ޾ਫ᪢҅ਙᵱᥝࢫᴚ౮ާጱ᭗ێݳ֢
    ݢզଆۗෆӻࢫᴚๅঅጱቘᥴӱۓ҅୏ݎ᫫կ̶
    ᥴ٬ԧFXFXPEHUጱӞԶᳯ᷌ԏݸ҅ݢզݎഀๅ୩य़ጱ֢አ̶
    ᭌೠӞྃᭇݳࢫᴚᛔ᫝ᵱᥝጱૡٍ҅಍ᚆכᦤࢫᴚᶲڥᬩ֢҅
    ੝ᩳ୦᪠̶

    View full-size slide

  40. ํᳯ᷌᧗ᘶᔮ
    ྷ᩻
    ஙמ im_mao_chao
    [email protected]
    ᨀᨀ

    View full-size slide