Skip to content

Testing ✔

Splines edited this page Aug 22, 2024 · 18 revisions

🌟 Unit tests

testing in vscode

In VSCode, you can install the recommended extension "Ruby Test Explorer". You must also have a recent version of python installed (at least Python3.8). Then go to tests and click on Run all tests. See the "Output" tab in VSCode for errors of the plugin. You can also go to a _spec.rb file and run tests from there individually.

Note that in the test explorer pane, you should prefer to use Run all tests instead of "Run tests" for the "models". This is because with "Run all tests" only one docker container will be created while for the latter, a new docker container is created for every new _spec.rb file. The creation of the docker container takes quite some time, so use Run all tests to get faster test results (really a lot faster, like ~15min vs. ~1min).

In other IDEs, use respective test extensions. From the shell you can invoke the tests using TODO (include just command).

Guidelines / tips

Troubleshooting

  • In VSCode, open the Output pane and choose Ruby Test Explorer Log to see the output of the extension. This is the place where you might find error messages, e.g. if no tests are shown in the test explorer.
  • One possible hickup might be a lost connection to the database. In this case, simply restart the db docker container in the test environment and it should work again.

Code coverage

We use Codecov to track our code coverage. See the dashboard here.


🌟 Cypress frontend tests

cypress frontend tests

We use Cypress as frontend Javascript testing framework. The cypress tests can be found in the spec/cypress/e2e/ folder. They will also run in our pipeline via GitHub Actions. To run them locally, use the following command:

just test cypress

Wait a few seconds for the Cypress test runner UI to show up (we're waiting for the MaMpf container to come online). Whenever you close this window, the Docker containers will automatically stop.

If you're using WSL, make sure to have an up-to-date version wsl --update (the latest version includes an X11 server by means of WSLg). After running the above command, a window should open up with the Cypress test runner UI. This window is GUI-forwarded from the Linux WSL system to your Windows system.

Note that cypress shares the test database with the Rails unit tests. This shouldn't be a problem as they both clean the whole database before they execute anything. But this means, we shouldn't run cypress and unit tests at the same time.

Guidelines / tips

Clone this wiki locally