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

ScalaでもDBのテストをしよう

 ScalaでもDBのテストをしよう

DbUnit?現役ですよ!

Kazumune Katagiri

April 09, 2016
Tweet

More Decks by Kazumune Katagiri

Other Decks in Technology

Transcript

  1. FactoryGirl • InsertจΛهड़͢Δ͜ͱແ͘ɺςετΫϥε͔Βલఏ৚݅ͷσʔλΛొ࿥͢Δ͜ͱ͕Ͱ͖Δ • σʔλͷதʹγεςϜ೔෇Λઃఆ • ొ࿥ͨ͠id߲໨Λผtableͷ֎෦Ωʔͱͯ͠ઃఆ [ςετΫϥε] val company1

    = FactoryGirl(Company).create() val country = FactoryGirl(Country, 'countryyy).create() val factory = FactoryGirl(Member).withVariables('countryId -> country.id) val member = factory.create('companyId -> company1.id, 'createdAt -> DateTime.now) [ઃఆϑΝΠϧ] countryyy { name="Japan" } member { countryId="#{countryId}" } company { name="FactoryGirl, Inc." } ઃఆϑΝΠϧΛݩʹσʔλΛొ࿥ɻ ඞཁʹԠͯ͡ςετΫϥεଆͰઃఆ͢Δ
  2. Ͷɺ؆୯ͦ͏Ͱ͠ΐʁ • ScalaTestΛ࢖͏͜ͱͰRSpecͷΑ͏ʹ΋ॻ͚Δ • AutoRollback traitΛ࢖༻͢Δ͜ͱͰςετ࣮ߦޙࣗಈͰrollback͢Δ • ෳ਺݅औಘ͢ΔSQLͷςετͷ৔߹ɺorder by Λ͚ͭͯৗʹಉ͡ॱ൪ͰऔಘͰ͖ΔΑ͏ʹҰ޻෉

    • ֎෦ΩʔΛ࢖͍ͬͯΔ࣌͸ɺσʔλͷొ࿥ॱʹ஫ҙ • ਌ςʔϒϧΛઌʹొ࿥ • ExcelͷσʔλಡΈࠐΈͰΤϥʔʹͳΔ࣌ • จࣈྻܕͷΧϥϜͳͷʹɺηϧ͕਺஋ / ೔෇ʹͳͬͯΔ͔΋ • ηϧΛจࣈྻܕʹ͢Δͱ͏·͘ߦ͘͜ͱ͕ଟ͍