Introduction
Writing test cases is a thing that a software developer should do. Writing tests to make sure the quality of project’s source code.
When developing application by Ruby on Rails framework, we often use Capybara.
So which library that we should use if we develop application by Elixir/Phoenix. Hound is an Elixir library for writing integration tests and browser automation. Hound is not a new library, I believe you guys can find a lot of tutorials on Internet that show how to use Hound in Elixir/Phoenix application.
In this post, I will show how to run the integration tests that written by Hound on Circle CI 2.0 for Phoenix application.
Circle CI 2.0
All we know when run integration tests on any CI environment, we need to config for the test can run on headless browser mode that will be setup before CI execute the test.
There are various tools out there to help with headless testing such as PhantomJS, Headless Chrome, Selenium. And there are also many ways to setup these tools on CI environment. For example: In Travis CI, we can use before_script
block to run the shell script to install headless testing tool. And in Circle CI 2.0, they supports browser testing out of the box. Sound cool, right?
Getting Started
Specify correct image
To enable headless testing on Circle CI 2.0, the primary image has the current stable version of Chrome pre-installed (this is designated by the -browsers
suffix). This means, your .circleci/config.yml
file needs to utilize an image with the -browsers
suffix.
1 | version: 2 |
Install Selenium driver
Hound use Selenium driver by default, so this step, I’m going to install Selenium on Circle CI 2.0:
1 | steps: |
Run the test
The final step is put all configurations together:
1 | version: 2 |
Conclusion
Getting Phoenix integration test and Circle CI to work in harmony is not difficult. Hope you enjoyed and feel free to let me know your comment. Thanks!