Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Concurrent Feature tests with Wallaby
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Chris Keathley
September 05, 2016
Programming
1.1k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Concurrent Feature tests with Wallaby
Chris Keathley
September 05, 2016
More Decks by Chris Keathley
See All by Chris Keathley
Solid code isn't flexible
keathley
5
1.2k
Building Adaptive Systems
keathley
44
3.2k
Contracts for building reliable systems
keathley
6
1.1k
Kafka, the hard parts
keathley
3
2k
Building Resilient Elixir Systems
keathley
7
2.5k
Consistent, Distributed Elixir
keathley
6
1.7k
Telling stories with data visualization
keathley
1
730
Easing into continuous deployment
keathley
2
470
Leveling up your git skills
keathley
0
870
Other Decks in Programming
See All in Programming
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
120
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
330
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
360
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
2
370
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
1
260
yield再入門 #phpcon
o0h
PRO
0
870
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
200
FDEが実現するAI駆動経営の現在地
gonta
2
250
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
270
その節約、円になってますか?
isamumumu
1
650
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
280
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
170
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
4 Signs Your Business is Dying
shpigford
187
22k
A Tale of Four Properties
chriscoyier
163
24k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
430
Product Roadmaps are Hard
iamctodd
55
12k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
160
Designing Experiences People Love
moore
143
24k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
Transcript
Concurrent Feature Tests with Wallaby Chris Keathley / @ChrisKeathley /
[email protected]
Feature tests: Driving tests from the UI
Name email Password Sign Up
Name email Password Sign Up Fill in
Name email Password Sign Up Fill in Click
Thanks for signing up! Did this show up?
Feature Tests
Feature Tests Represent real users
Feature Tests Represent real users Provide Confidence in the System
Feature Tests Represent real users Provide Confidence in the System
Dark Side
Feature Tests Represent real users Provide Confidence in the System
Feature Tests Represent real users Provide Confidence in the System
(Sometimes)
Feature Tests Represent real users Provide Confidence in the System
(Sometimes) (When they aren’t randomly failing)
Happens
Feature Tests ARE Slow
Wallaby
Wallaby Manages multiple browsers Concurrent Assumes async Interfaces
Wallaby TL;DR
Name email Password Sign Up
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end Sessions Queries actions
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end Sessions Queries actions
Wallaby Phoenix EcTo Test Sessions
Wallaby Phoenix EcTo Test Sessions Browser
Wallaby Phoenix EcTo Test Sessions Browser Browser
Wallaby Phoenix EcTo Test Sessions Browser
setup tags do {:ok, session} = Wallaby.start_session([]) on_exit, fn ->
Wallaby.end_session(session) end {:ok, session: session} end
Browser Browser Phoenix Ecto
Browser Browser Phoenix Ecto
Browser Browser Phoenix Ecto
Browser Phoenix Ecto
Browser Phoenix Ecto Ownership Metadata
Browser Phoenix Ecto Ownership Metadata Transaction Ownership
setup tags do {:ok, session} = Wallaby.start_session([]) on_exit, fn ->
Wallaby.end_session(session) end {:ok, session: session} end
setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(YourApp.Repo) metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for( YourApp.Repo,
self()) {:ok, session} = Wallaby.start_session(metadata: metadata) on_exit, fn -> Wallaby.end_session(session) end {:ok, session: session} end
setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(YourApp.Repo) metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for( YourApp.Repo,
self()) {:ok, session} = Wallaby.start_session(metadata: metadata) on_exit, fn -> Wallaby.end_session(session) end {:ok, session: session} end
setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(YourApp.Repo) metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for( YourApp.Repo,
self()) {:ok, session} = Wallaby.start_session(metadata: metadata) on_exit, fn -> Wallaby.end_session(session) end {:ok, session: session} end
setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(YourApp.Repo) metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for( YourApp.Repo,
self()) {:ok, session} = Wallaby.start_session(metadata: metadata) on_exit, fn -> Wallaby.end_session(session) end {:ok, session: session} end
defmodule YourApp.Endpoint do use Phoenix.Endpoint, otp_app: :your_app if Application.get_env(:your_app, :sql_sandbox)
do plug Phoenix.Ecto.SQL.Sandbox end plug YourApp.Router end
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end Sessions Queries actions
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end Sessions Queries actions
Thanks for signing up!
Thanks for signing up! <div class="alert"> <span class=“msg"> Thanks for
signing up! </span> </div>
Thanks for signing up! <div class="alert"> <span class=“msg"> Thanks for
signing up! </span> </div> session |> find(“.alert")
Thanks for signing up! <div class="alert"> <span class=“msg"> Thanks for
signing up! </span> </div> session |> find(“.alert")
<div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span
class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div> HTML
<div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span
class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div> HTML Test - User Names session
<div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span
class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div> HTML Test - User Names session |> find(".user")
<div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span
class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div> HTML Test - User Names session |> find(".user") Ambiguous
<div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span
class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div> HTML Test - User Names session |> find(".user", count: 2)
<div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span
class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div> HTML Test - User Names session |> find(".user", count: 2) |> Enum.map(& find(&1, ".name") )
<div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span
class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div> HTML Test - User Names session |> find(".user", count: 2) |> Enum.map(& find(&1, ".name") ) |> Enum.map(& text(&1) ) # => ["Grace Hopper", "Alan Turing"]
session HTML Test - Grace’s Email <div class="users"> <div class="user">
<span class=“name"> Grace Hopper </span> <span class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div>
session |> find(".user", text: "Grace Hopper") HTML Test - Grace’s
Email <div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div>
session |> find(".user", text: "Grace Hopper") |> find(".email") HTML Test
- Grace’s Email <div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div>
session |> find(".user", text: "Grace Hopper") |> find(".email") |> text
# => "
[email protected]
" HTML Test - Grace’s Email <div class="users"> <div class="user"> <span class=“name"> Grace Hopper </span> <span class=“email">
[email protected]
</span> </div> <div class="user"> <span class=“name"> Alan Turing </span> <span class=“email">
[email protected]
</span> </div> </div>
find(".user") ? Browser
find(".user") JS Browser
find(".user") JS Browser
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end Sessions Queries actions
defmodule YourApp.UserRegistrationTest do use YourApp.AcceptanceCase, async: true test "users can
register", %{session: session} do session |> visit("/users/new") |> find(".registration_form") |> fill_in("Full Name", with: "Grace Hopper") |> fill_in("Email", with: "
[email protected]
") |> fill_in("Password", with: "password") |> click("Register") msg_text = session |> find(".flash-message") |> text assert msg_text == "Welcome Grace Hopper" end end Sessions Queries actions
Name Sign Up
<form> <label for=“user_name"> Name </label> <input type="text" name=“user_name"> <button type=“submit">
Register </button> </form> HTML
HTML <form> <label for=“user_name"> Name </label> <input type="text" name=“user_name"> <button
type=“submit"> Register </button> </form>
<form> <label for=“user_name"> Name </label> <input type="text" name=“user_name"> <button type=“submit">
Register </button> </form> HTML Test session
<form> <label for=“user_name"> Name </label> <input type="text" name=“user_name"> <button type=“submit">
Register </button> </form> HTML Test session |> fill_in("Name", with: "Grace Hopper")
<form> <label for=“user_name"> Name </label> <input type="text" name=“user_name"> <button type=“submit">
Register </button> </form> HTML Test session |> fill_in("Name", with: "Grace Hopper") |> click_on("Register")
HTML Test session |> fill_in(“user_name", with: "Grace Hopper") |> click_on("Register")
<form> <label for=“user_name"> Name </label> <input type="text" name=“user_name"> <button type=“submit"> Register </button> </form>
HTML Test session |> fill_in(“user_name", with: "Grace Hopper") |> click_on("Register")
<form> <label for="user_name"> Name </label> <input type="text" name=“user_name"> <label> <input type="checkbox" value="true" name="save_login"> Save login </label> <button type="submit"> Register </button> </form>
HTML Test session |> fill_in(“user_name", with: "Grace Hopper”) |> check("Save
login") |> click_on("Register") <form> <label for="user_name"> Name </label> <input type="text" name=“user_name"> <label> <input type="checkbox" value="true" name="save_login"> Save login </label> <button type="submit"> Register </button> </form>
fill_in(session, "First Name", with: "Chris") choose(session, "Radio Button 1") check(session,
"Checkbox") uncheck(session, "Checkbox") select(session, "My Awesome Select", option: "Option 1") click_on(session, "Some Button") attach_file(session, "File", path: "path/to/file") Other Actions
Wallaby Sessions Queries Interactions
Still More work to do!
https://github.com/keathley/wallaby https://speakerdeck.com/keathley Getting Started
None
None
Lets Build awesome stuff Together!
THANKS Chris Keathley / @ChrisKeathley /
[email protected]