/stbernard

Bare bones series of webpages to demonstrate testing Elixir code with Hound

Primary LanguageHTML

St Bernard

St Bernard is a simple series of webpages used to demonstrate the howling success of the Hound testing tool.

Whatever you call it, UI testing/End-to-End Testing/End-to-User Testing/Acceptance Testing--it is often an intensely manual and time-consuming process. Hound carries some of the load through browser automation. Browser automations means that I can automate my user interactions — clicks, fill inputs, file uploads, selecting options, radio buttons, etc. I use this app to demonstrate an overview of Hound and it’s helpers, as well as an example of how Hound tests saved me days of manual end-user testing.

Bone Simple Creation

Create a simple Phoenix called St Bernard.

$ mix phx.new stbernard --no-ecto

Add Hound as a dependency in mix.exs.

{:hound, "~> 1.0"}

Hound requires a webdriver for browser automation. We will use selenium. Install and run:

$ brew install selenium-server-standalone
$ selenium-server

Start Hound in test/test_helpers.exs. Add this above ExUnit.start()

Application.ensure_all_started(:hound)

In config/test.exs add:

config :hound, browser: "chrome"

. . . and set server to true:

config :stbernard, StbernardWeb.Endpoint,
  http: [port: 4001],
  server: true

Start the Phoenix server

  • install dependencies with mix deps.get
  • install Node.js dependencies with cd assets && npm install
  • start interactive elixir: iex -S mix phx.server
  • visit localhost:4000 from your browser.

Run tests (in this demo app, Hound is used as a part of ExUnit tests)

$ mix test

Lab-ra-cadabra!

The acceptance tests live in test/stbernard_web/integration/

- test/
  - stbernard_web/
    - acceptance/
      - form_test.exs
      - charge_test.exs
      - welcome_test.exs
  - test_helper.exs

Simple welcome_test.exs

Complex form_test.exs

TODO

  • demonstrate how to select a value from an autocomplete input field with Awesomplete
  • demonstrate Metadata in Hound session
  • demonstrate change_session_to/2 to use multiple browser sessions for permutations

Go Fetch!