Client-Side Test Cases
Odoo provides a way to run client-side test cases from the UI. By running the test case
from the UI, you will be able to see each step of the test case in action. This way, you
can verify that the UI test case is working exactly as we wanted.
You can run both the QUnit test case and the tours test case from the UI. It is not
possible to run Python test cases from the UI as it runs on the server-side. In order to
see the options to run test cases from the UI, you need to enable developer mode.
Running QUnit test cases from the UI
Activate developer mode and click on the bug icon and Click on the Run JS
Tests option:
This will open the QUnit suite and it will start running the test cases one by one, as
shown in the following screenshot. By default, it will only show failed test cases. To
show all the passed test cases, uncheck the Hide passed tests checkbox,
as shown in the following screenshot:
Running tours from the UI
Activate developer mode and click on the bug icon and then click on Start
Tour:
This will open the dialog with a list of registered tours, as you can see in the
following screenshot. Click on the play button on the side to run the tour:
Video/Screenshots For Failed Test Cases
Odoo uses Headless Chrome. This opens additional opportunities. Beginning from Odoo 12,
you can record recordings of the failed test cases, or you can take screen captures of
the failed test cases too.
Generating Video/Screenshots
Recording a video for the test case requires ffmpeg package.
- Command to install ffmpeg package in python
apt-get install ffmpeg
If you want to generate screencast (video) of a test case, use the
--screencasts command:
./odoo-bin -c server.conf -i my_module --test-enable
--screencasts=/home/odoo/odoo_test/
If you want to generate screenshots of a test case, use the
--screenshosts command:
./odoo-bin -c server.conf -i my_module --test-enable
--screenshots=/home/odoo/odoo_test/
To produce screen captures/screencasts for the failed tests, you want to run the server
with the path to save the video or picture records. Whenever you run the test, and if a
test falls, Odoo will save a screen capture/video of the failed test case in the given
registry.
To generate a video of a test case, Odoo uses the ffmpeg package. If you
haven't installed this package on the server, then it will only save a screenshot of a
failed test case. After installing the package, you will be able to see the
mp4 file of any failed test case.