Exunitはセットアップブロックhttps://hexdocs.pm/ex_unit/ExUnit.Callbacks.htmlのコールバックを提供しているようです。私はそれがwallaby機能テストでどのようにできるのか不思議です。私は基本的に、統合テストをテストする際には、すべてのシナリオでユーザーを作成します。私は基本的に定型コードを取り出して、私が書いたすべてのテストに使用したいと思っています。ここでは、統合テストのための私の現在の設定です。エリキシルのテストへの設定の追加
test "a user can create a location", %{session: session} do
assert session
|> visit("/users")
|> click_link("Create new account")
|> fill_in("Name", with: "Billy Joel")
|> fill_in("Email", with: "[email protected]")
|> fill_in("Password", with: "password")
|> click_on("Create new user")
|> click_link("New Project")
|> fill_in("Name", with: "Senior Class Air Quality")
|> click_on("Submit")
|> click_link("Senior Class Air Quality")
|> click_link("New Location")
|> click_on("Submit")
|> find(".alert-danger p")
|> text == "Oops, something went wrong! Please check the errors below."
assert session
|> fill_in("Name", with: "A new location")
|> select("Type", option: "office")
|> click_on("Submit")
|> find(".alert-info")
|> text == "Location created successfully."
assert session
|> find("td", count: 3)
|> List.first
|> text == "A new location"
end
test "a user can edit a location", %{session: session} do
project = Factory.project()
Factory.location(%{project_id: project.id})
assert session
|> visit("/users")
|> click_link("Create new account")
|> fill_in("Name", with: "Billy Joel")
|> fill_in("Email", with: "[email protected]")
|> fill_in("Password", with: "password")
|> click_on("Create new user")
|> click_link("New Project")
|> fill_in("Name", with: "Senior Class Air Quality")
|> click_on("Submit")
|> click_link("Senior Class Air Quality")
|> click_link("New Location")
|> fill_in("Name", with: "A new location")
|> select("Type", option: "office")
|> click_on("Submit")
|> click_link("Edit location")
|> fill_in("Name", with: "different name")
|> select("Type", option: "home")
|> click_on("Submit")
|> find(".alert-info")
|> text == "Location updated successfully."
そこには重複が多数あります。セットアップブロックを使用してこのコードの一部を統合するにはどうすればよいですか?