? ?
avatar sakiss
sakiss
13 Jul 2020

Problem identified

The unit-test repo is archived
https://github.com/joomla/test-unit

Open questions

What is the suggested way for running unit tests in Joomla 4 context?

avatar sakiss sakiss - open - 13 Jul 2020
avatar joomla-cms-bot joomla-cms-bot - change - 13 Jul 2020
Labels Added: ? ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 13 Jul 2020
avatar joomla-cms-bot joomla-cms-bot - labeled - 13 Jul 2020
avatar PhilETaylor
PhilETaylor - comment - 13 Jul 2020

I just checkout from git, switch branch to 4.0-dev, composer install (and all the asset build) and then just run

./libraries/vendor/bin/phpunit

most will fail locally due to no test db connection but you can run individual tests eg:

./libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/VersionTest.php

avatar mbabker
mbabker - comment - 13 Jul 2020

That repo was from a poorly thought through workflow for this repo's automated tests, where all the tests lived in separate repositories from this one.

Check the Drone configuration file, or whatever the flavor of the month CI integration that goes against the rest of what the PHP ecosystem uses is; that should always have the correct commands to build a proper test environment and run the tests.

avatar astridx
astridx - comment - 13 Jul 2020

What is the suggested way for running unit tests in Joomla 4 context?

Please see also this Read.me.

https://github.com/joomla/joomla-cms/blob/4.0-dev/tests/Unit/README.md

avatar richard67
richard67 - comment - 14 Jul 2020

@sakiss Please check the answers above, especially the one before this comment, and if it answers your question please close this issue here. Thanks in advance.

avatar sakiss
sakiss - comment - 14 Jul 2020

From my understanding, the joomla/test-unit repo is no longer used and the tests can run solely by using the phpunit framework.
I will try to generate and run some unit tests, but if someone can confirm the above, is welcome.

avatar astridx
astridx - comment - 15 Jul 2020

Does this answer your question: #23962

If you want to know more, maybe someone from this team (Do you even want to join?) will help you.
https://volunteers.joomla.org/teams/automated-tests-working-group

avatar sakiss
sakiss - comment - 16 Jul 2020

Thank you all for your feedback!

My conclusions regarding unit testing in Joomla 4 are:

  1. We no longer need the joomla/test-unit repo for our tests.
    If we are running tests for the Joomla framework, the https://github.com/joomla/joomla-cms/tree/staging/tests , is enough.

  2. If we want to have tests in the component level, we need:
    a. The phpunit/phpunit repo, in our system.
    b. Our own php-unit.xml, with a bootstrap attribute that points to a new bootstrap file and a testsuites node that points to the tests folder.
    c. Our bootsrap file can be a copy of https://github.com/joomla/joomla-cms/blob/4.0-dev/tests/Unit/bootstrap.php , but we have to change the $rootDirectory, to point to our Joomla root, the JPATH_CACHE, to point to our cache folder (site or admin) and also load the necessary namespaces, used for the extensions (administrator/cache/autoload_psr4.php).

avatar sakiss sakiss - close - 16 Jul 2020
avatar sakiss sakiss - change - 16 Jul 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-07-16 10:32:16
Closed_By sakiss

Add a Comment

Login with GitHub to post a comment