I started working on an automated test bench. Currently it supports both using pytest and the QGIS unittest framework, using qgis_testrunner.sh (comes with the Qgis docker image), as I was still unsure what we would require.
The latter has the benefit that there are plenty of examples available in the
Qgis repo itsself.
And this also is what the developers expect you to use when using their docker image, for which there is (spare) documentation
in the Readme here
The qgis_testrunner.sh still behaves a bit oddly, as it prints that it cannot find the module, but later in the actual test it can, and the test gives an OK. The part of the qgis_testrunner.sh script that counts fails and successes is bugged as well for the created logs, changing the lines of code to grep reading the logfile directly, so
grep -c FAILED /tmp/qgis_testrunner_*** instead of echo $OUTPUT | grep -c FAILED, fixed it for me in some local tests. I probally have to raise an issue for that.
TODO
[x] Add tests for the plugin ittself.
Installing dependencies to run Github Actions on Windows
This is because WSL2 + Docker apparently require absolute paths to refer to stuff on the mount, so c:/ instead of the usual /mnt/c/ (which is what is returned by ${GITHUB_WORKSPACE} locally.
You can then run the workflow by cd'ing into the repo (e.g. cd c:\src\imod-qgis) and calling act.
Tips running locally on Windows
WSL2 hides Linux files, if you want to get an idea what is going on here, you can use Total Commander or Windows Explorer, and navigate to the hidden network drive \\wsl$\. Microsoft warns you not to edit any of these files using Windows tools. I tried modifying some file in Notepad++, paying close attention to only have LF and no carriage returns, but this still broke Docker.
Docker Desktop has a neat feature to open a container in a console. You can find it by navigating to 'Apps/Containers' -> "qgis-testing-environment" -> 'CLI' . You can interactively check here what on earth happened in your workflow, e.g. by checking files or modifying and rerunning some scripts again.
Description
I started working on an automated test bench. Currently it supports both using pytest and the QGIS unittest framework, using
qgis_testrunner.sh
(comes with the Qgis docker image), as I was still unsure what we would require.The latter has the benefit that there are plenty of examples available in the Qgis repo itsself. And this also is what the developers expect you to use when using their docker image, for which there is (spare) documentation in the Readme here
The
qgis_testrunner.sh
still behaves a bit oddly, as it prints that it cannot find the module, but later in the actual test it can, and the test gives an OK. The part of theqgis_testrunner.sh
script that counts fails and successes is bugged as well for the created logs, changing the lines of code to grep reading the logfile directly, sogrep -c FAILED /tmp/qgis_testrunner_***
instead ofecho $OUTPUT | grep -c FAILED
, fixed it for me in some local tests. I probally have to raise an issue for that.TODO
Installing dependencies to run Github Actions on Windows
Run locally on Windows
For installing docker on Windows, see below.
To run the tests locally change in
.github/workflows/tests.yml
(assuming you have your repo underc:\src\imod-qgis
:to
This is because WSL2 + Docker apparently require absolute paths to refer to stuff on the mount, so
c:/
instead of the usual/mnt/c/
(which is what is returned by${GITHUB_WORKSPACE}
locally.You can then run the workflow by
cd
'ing into the repo (e.g.cd c:\src\imod-qgis
) and callingact
.Tips running locally on Windows
\\wsl$\
. Microsoft warns you not to edit any of these files using Windows tools. I tried modifying some file in Notepad++, paying close attention to only have LF and no carriage returns, but this still broke Docker.Example repos I used ideas from: