↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Writing Acceptance tests in Phoenix

The post walks through adding Hound to a Phoenix app and using PhantomJS as a headless driver for acceptance tests. It also shows how to set up a shared IntegrationCase, start Hound during test runtime, and configure the test server so browser-driven tests can run.

Reading notes
#

  • Hound is presented as a tool for writing acceptance tests in the Elixir ecosystem.
  • The example uses an expenses report listing page and interacts with report data and form elements.
  • Hound supports chrome_driver, firefox, phantomjs, and selenium, and the author chooses phantomjs for headless execution.
  • The setup adds Hound to mix.exs, starts it in the test helper, configures the driver in config.exs, and enables the server in config/test.exs.
  • A shared IntegrationCase is created to include Hound.Helpers, Ecto helpers, router helpers, and hound_session.
  • The test file defines helpers to check whether an expense appears in the list, collect table rows, and select a status value in a form.
  • The tests navigate directly to the city expenses page in setup and reuse that city across the examples.
  • One test filters expenses by supplier, fills the supplier field, submits the form, and checks that only the expected expense remains.
  • Another test filters by status, first selecting cancelled and then paid, reloading the form between submissions because the element cache can become invalid.
  • The post says acceptance tests are slower and the suite runtime tripled after adding two such tests.
  • It recommends keeping acceptance tests as a small part of the test pyramid and preferring controller tests in most cases.
  • PhantomJS is described as faster than the other options mentioned.
  • The post notes that Hound does not start the browser automatically, so it must be started separately before running tests.