-
Notifications
You must be signed in to change notification settings - Fork 8
Running Tests
- Running tests via Docker
- Running RSPEC tests
- Running tests inside running Docker container
- Trouble shooting
You can run tests via Docker in two steps.
You first have to build the test image.
You can specify test set with -f flag.
Without the f flag, it will run all of the tests.
./build_test.sh
./run_test.sh -r RAILS_ENV_FILE
./run_test.sh -r RAILS_ENV_FILE -f features/assumption/assume.feature
You can run RSPEC tests via Docker by supplying -s flag.
You can specify test set with -f flag.
Without the f flag, it will run all of the tests.
./run_test.sh -sr RAILS_ENV_FILE
./run_test.sh -sr RAILS_ENV_FILE -f spec/helpers/advanced_helper_spec.rb
Running test directly as above will require you to build the test image each time you make a change to the test suite you are working on.
You can ssh into the test container and make changes and run tests interactively.
In the interacitve mode, -f parameter will be ignored if provided.
When you log into the running container, the prompt will show that your are logged in as root on the container id and that your are inside /workspaces/blacklight-cornell directory, e.g. root@CONTAINER_ID:/workspaces/blacklight-cornell#
You can either specify a test feature at the end or run all of the tests without any arguments.
./run_test.sh -ir RAILS_ENV_FILE
root@###:/workspaces/blacklight-cornell# ./jenkins-opts.sh
root@###:/workspaces/blacklight-cornell# ./jenkins-opts.sh features/assumption/assume.feature
root@###:/workspaces/blacklight-cornell# bundle exec rspec
root@###:/workspaces/blacklight-cornell# bundle exec rspec spec/helpers/advanced_helper_spec.rb
Interactive mode does more than running tests inside the container, however.
It mounts the source directory to /workspaces/blacklight-cornell and any changes will be reflected immediately without having to rebuild the test image.
The /blacklight-cornell directory contains the source files from the container itself.
After you start an interactive session, you can log into the running test instance from different terminal by simply calling the test script without any arguments.
The same applies to rails app - after you start the rails app with run.sh, you can run run.sh without any arguments to log into the running container.
We have experienced random test failures after dockerizing the tests.
It turned out to be resource problem.
Try increasing resources to Docker from the Docker Desktop.
Go to settings (gear icon) -> Resources -> Advanced and adjust settings.