Skip to content

Testing

Jonathan Stray edited this page Apr 4, 2017 · 4 revisions

There are three kinds of tests: Scala unit tests (back end), Coffeescript unit tests (front end), and integration tests.

Many tests require a test database or search index. Like Overview's other required services, these are set up through docker-compose.yml. The test database is called overview-test on the same overview-dev-database Postgres container, while the test Elastic Search is a completely different container called overview-test-searchindex.

If you get errors like this:

[error] com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization: Connection to 192.168.99.100:9010 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. (HikariPool.java:581)

Most likely you have forgotten to do docker-compose start first.

Run all tests on release build

auto/test-everything.sh

This builds Overview in its release configuration, then sets up and runs all back end unit tests, front end unit tests, and integration tests. You can look into this file to see how everything works. It takes a while.

Running Scala unit tests

First, make sure the development services are up: docker-compose start

Before the first time you run the tests, you need to bring the test db up to date.

./sbt test-db-evolution-applier/run

After that, it's just

./sbt all/test

This tests all projects. To test specific projects, use

./sbt app/test ./sbt common/test ./sbt worker/test

Run only specific unit tests

./sbt "test-only *DocumentSetFileControllerSpec"

This will work for the main server (aka overview-web). To do this for another project, e.g. worker, common, do

./sbt "; project common; test-only *ContentDispositionSpec"

Automatically re-run tests

To run unit tests every time you change a file in app/ or test/, run ./sbt ~test-quick.

Beware: .sbt run will also recompile any changed files in app/ or test/ whenever you reload a page. If you run both commands simultaneously, sbt will destroy its own files, leading to errors. Train yourself to wait for ./sbt ~test-quick to finish its work before you refresh the page.

Running Integration tests

Set up the test suite:

  1. Install NodeJS. npm must be in your path.
  2. Run auto/setup-integration-tests.sh from your overview-server checkout. This will run an npm install command.

And now run the integration test suite:

./run # and keep it running in the background
auto/test-integration.sh

Clone this wiki locally