Skip to content

A sample project that shows how to write truly end-to-end tests in Scala

Notifications You must be signed in to change notification settings

unthought/scala-e2e-testing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-e2e-testing

This is a sample project that shows how to write truly end-to-end tests in Scala. It accompanies a talk I gave at Scalapeno 2014 titled "True End-to-End Testing in Scala".

Project

This project uses:

  • Sbt for the build and the test harness
  • Vagrant for running the tests in
  • Ansible for deployment and automation
  • Maven repository for artifact publishing and distribution

Scala App

The app itself is a finatra-based "micro-service" (choosing finatra was an arbitrary decision, it could just as easily be another server framework/library, like Play, plain finagle, spray, etc.).

The simple example app is a notes-taking web service, which allows storing, retrieving, searching for and translating notes, and is named memento. It exposes a REST API and returns JSON.

The app is composed of two modules: core and finatra. The core contains as much of the code as possible, and includes unit and integration tests. The finatra module is the server aspect, and only contains the controller/http layer. It's modeled so we can later on easily replace the server module and use a different library/framework as our http server (or something else completely). Our end-to-end tests reside in this module.

Infrastructure/Architecture

The architecture includes:

  • Ubuntu for the operating system
  • HAProxy as a load balancer
  • Nginx as an http server in front of the finatra app server (reverse proxy)
  • Elasticsearch as the datastore

Git Repositories

The scala app and ansible playbooks are joined here in the same git repository mainly for brevity and ease-of-use. It is suggested that real projects separate them into two repositories (or more if you have more then one deployable) to allow more flexibility, but this is up to you.

Requirements

To run the tests the following should be installed on your dev machine:

Running The Tests

There are 3 testing modes:

  • test for running unit tests
  • it:test for running integration tests
  • e2e:test for running end-to-end tests

To run all tests together:

$ cd ./memento
$ sbt test-all

Running Ansible Manually

If you want to test only the ansible code, run:

$ ansible-playbook -i ansible/inventories/vagrant ansible/site.yml

About

A sample project that shows how to write truly end-to-end tests in Scala

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 93.4%
  • Shell 6.5%
  • HTML 0.1%