-
Notifications
You must be signed in to change notification settings - Fork 37
Testing
There are three kinds of tests: Scala unit tests, JavaScript unit tests, and integration tests.
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
Scala unit tests require a test database. Like Overview's other required services, these are set up through docker-compose.yml. The test database is called overview-test on the same database Postgres container.
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.
./sbt "testOnly *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; testOnly *ContentDispositionSpec"
To run unit tests every time you change a file in web/
, run ./sbt '; project web; ~testQuick'
.
Beware: ./dev
recompiles changed files whenever you reload a page. If you run both ./dev
and ./sbt ... ~testQuick
simultaneously, the processes can overwrite one another's data files, causing errors. Train yourself to wait for ~testQuick
to finish before you refresh the page.
If you're running ./dev
, you can integration-test against that: integration-test/run
Alternatively, to integration-test against a production-style cluster, run ./docker/build
to build Docker images and then run integration-test/run-in-docker-compose
to spin up the cluster and test against it.