Add code testing via phpunit and/or cypress#167
Add code testing via phpunit and/or cypress#167parapente wants to merge 52 commits intojmcameron:masterfrom
Conversation
…able two joomla extensions that could cause issues in tests
|
Hello it seems to be a big work. |
|
For phpunit:
For cypress:
|
|
@parapente for phpunit I have an error at st step 1) |
|
I fixed last error by adding link from temp\joomla\libraries\src to joomla 4.x library src path |
|
Next error is |
|
@JLTRY yes that is the error I'm getting too. The summary gives: but most of those that pass as quite trivial tests. Another thing that will be of importance if we continue to work with phpunit is that the joomla framework packages have different numbering from the joomla cms releases:
So for the packages that I have added as requirements in composer.json we should use the joomla 6 code in /temp/joomla. |
|
I have made a link to joomla_6 libraries/src. It still fails I have got this error |
|
@JLTRY I managed to make the tests run correctly: I am not 100% happy with the state of the code but it at least works. I will review the code on the weekend to untangle the mess I created just to make it work. Joomla has many interconnected parts that makes it difficult to run such tests without running a web server & database. Feel free to test on your end for any issues. |
|
@parapente Any advice ? |
|
@JLTRY You need to install the php sqlite extension to be able to run the tests. By the way I forgot to mention that there are some data missing from the repository that were used to initialize some tables with data. They are not really necessary but this is the reason you will see some hard coded values in the code. I will need to extract those values in a seperate structure. |
|
Runtime: PHP 8.3.3 ..........WW.WWWWWWWWW......................................... 63 / 222 ( 28%) Time: 00:03.729, Memory: 16.00 MB OK, but there were issues! |
|
@parapente To be noticed that we can tell phpunit to be more verbose by setting
Triggered by:
|
|
I did check the warnings/deprecations using the switches --display-warnings and --display-deprecations but the ones that are left don't really matter much. They are not in our code but due to the way the code is running some joomla function fails to return an array and that is why we get the warning/deprecation. While refactoring the test code I will revisit the warning in case I can make the test skip this joomla plugin function. |
|
@JLTRY I tried to rebuild the |
|
I checked the unit tests and it is OK for me |
This is an effort to add automated testing of the code to ensure that the extension works whenever new patches are added to the codebase or the joomla framework changes.
There are few phpunit tests (ported from older tests that were present in the codebase) but almost all fail for now. It will need quite some effort to refactor the extension code to be able to test it effectivly using phpunit.
Cypress on the other hand can help us test the extension as it is running on an joomla instance like we would manually. I started adding some basic tests that are run in batches. I have created folders for each part of the package in /cypress/e2e that eventually will be populated with the tests.
I will add a checklist for everything that needs to be done and of course the last step would be to add github actions to run the tests whenever we push code to master.