-
Notifications
You must be signed in to change notification settings - Fork 37
Testing
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.
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.
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
./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"
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.
Set up the test suite:
- Install NodeJS.
npmmust be in your path. - Run
auto/setup-integration-tests.shfrom youroverview-servercheckout. This will run annpm installcommand.
And now run the integration test suite:
./run # and keep it running in the background
auto/test-integration.sh