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

E2E testing on Rails 2023

Yusuke Iwaki
October 27, 2023

E2E testing on Rails 2023

Kaigi on Rails 2023 発表スライド

Yusuke Iwaki

October 27, 2023
Tweet

More Decks by Yusuke Iwaki

Other Decks in Technology

Transcript

  1. MPDBMIPTUMPHJO $BQZCBSB #SPXTFS υϥΠό $BQZCBSB 4FTTJPO pMM@JO pMM@JO pOE TFU

    -PHJO MPDBMIPTUMPHJO -PHJO JOQVU<OBNFVTFSOBNF> :VTVLF*XBLJ
  2. QMBZXSJHIUDPO fi HUT w QSPKFDUTͰ؀ڥهड़ w $ISPNJVN 'JSFGPY 8FC,JUʹɹ ΑΔςετ

    w XFC4FSWFSͰςεταʔόʔهड़ w ෳ਺αʔόʔىಈ΋Մೳ
  3. DZQSFTTSBJMT w 1VNB ςεταʔόʔ $ZQSFTTηοτͷಠࣗςετ؀ڥΛཱͯΔ w SBLFDZQSFTTYYYͱ͍͏DZQSFTTϥοϓίϚϯυ͕༻ҙ͞Ε͍ͯΔɻ w σϑΥϧτͰ͸3"*-4@&/7UFTUͰαʔόʔىಈ w

    1VNBαʔόʔىಈ෦෼͸ɺ$BQZCBSBͷίʔυͷίϐʔ࣮૷ w 5SBOTBDUJPOBM5FTUΛߦ͏ɻ%#ίωΫγϣϯڞ༗ʢMPDL@UISFBEʣ͸ɹɹ ΄ͱΜͲ"DUJWF3FDPSEͷίʔυͷίϐʔ࣮૷
  4. DZQSFTTSBJMT 1VNB ಠࣗϛυϧ΢ΣΞ SBLFDZQSFTTSVO (&5@@JEFOUJUZ@@ ϧʔτఆٛ ىಈ׬ྃ͢Δ·ͰϙʔϦϯά (&5@@JEFOUJUZ@@ (&5DZQSFTT@SBJMT@SFTFU@TUBUF ϧʔτఆٛ

    3"*-4@&/7UFTUͰαʔόʔىಈ $ZQSFTTىಈ DZQSFTTSVO beforeEach(() => { cy.request('/cypress_rails_reset_state') }) GET /cypress_rails_reset_state GET /cypress_rails_reset_state UFTU %# ROLLBACK BEGIN ROLLBACK BEGIN reset_stateϦΫΤετΛड͚ͨ ࣍ͷHTTPϦΫΤετ࣌ʹ ROLLBACKͱBEGIN͢Δ
  5. ϞοΫελϒ w 34QFDͩͱಛఆͷςετͷ͚ؒͩϝιουͷڍಈΛม͑Δ͜ͱ͸Ͱ͖Δ w BMMPX@BOZ@JOTUBODF@PGʜ 3F fi OFNFOUT ͳͲ w

    (&5IPHF͞Ε͔ͯΒ(&5GVHB͞ΕΔ·ͰϞοΫ͸Ͳ͏͢Δɾɾɾʁ w ຊ౰ʹͳ͍ͳΒࣗ෼Ͱ࡞Δ͔͠ͳ͍ʜ
  6. TJNQMF@TUVC ಠࣗϛυϧ΢ΣΞ ςετલ४උ DVSSFOU@VTFSΛϞοΫ ςετલ४උ VTFSΛ̍ਓ࡞੒ ςετޙॲཧ DVSSFOU@VTFSϞοΫղআ 1045@@FF@@FWBM 4JNQMF4UVCGPS@JOTUBODF@NFUIPE

     "QQMJDBUJPO$POUSPMMFS  DVSSFOU@VTFS \6TFS fi STU^BQQMZ 1045@@FF@@FWBM 4JNQMF4UVCGPS@JOTUBODF@NFUIPE  "QQMJDBUJPO$POUSPMMFS  DVSSFOU@VTFS \6TFS fi STU^SFTFU
  7. ʂ

  8. ʂ ಠࣗϛυϧ΢ΣΞ +PIOΛ࡞੒ͯ͠ $VSSFOUVTFSʹ *%:VTVLF*XBLJ 1BTT  ͰϩάΠϯ %BTICPBSETQFD -PHJOTQFD

    +PIO $VSSFOUVTFS /PEFKTϕʔεͷςετϥϯφʔ͸ ϊϯϒϩοΩϯά*0ϑϧ׆༻ جຊతʹ͸ฒྻςετʂ
  9. ʂ ಠࣗϛυϧ΢ΣΞ +PIOΛ࡞੒ͯ͠ $VSSFOUVTFSʹ *%:VTVLF*XBLJ 1BTT  ͰϩάΠϯ %BTICPBSETQFD -PHJOTQFD

    +PIO $VSSFOUVTFS $BQZCBSBͷͱ͖ʹฒྻ࣮ߦͳΜͯ ҙࣝͯ͠ॻ͍ͯͳ͔ͬͨʜPS[
  10. 4IBSEJOHͰແཧ΍ΓฒྻԽʜ %BTICPBSETQFD -PHJOTQFD ಠࣗϛυϧ΢ΣΞ %# ಠࣗϛυϧ΢ΣΞ %# +PIO $VSSFOUVTFS :VTVLF*XBLJ

    OQYQMBZXSJHIUUFTU ŠTIBSEŠSFQPSUFSCMPC OQYQMBZXSJHIUUFTU ŠTIBSEŠSFQPSUFSCMPC 1035  1035 
  11. 4IBSEJOHͰແཧ΍ΓฒྻԽʜ %BTICPBSETQFD -PHJOTQFD ಠࣗϛυϧ΢ΣΞ %# ಠࣗϛυϧ΢ΣΞ %# +PIO $VSSFOUVTFS :VTVLF*XBLJ

    OQYQMBZXSJHIUUFTU ŠTIBSEŠSFQPSUFSCMPC OQYQMBZXSJHIUUFTU ŠTIBSEŠSFQPSUFSCMPC QPSU  QPSU  ίϨδϟφΠײ ฒྻςετ͸ըظత͕ͩɺզʑʹ͸·ͩ଎͗͢Δɻ