Joomla-cms: [RFC] Joomla's unit-test repo?

Created on 13 Jul 2020  路  7Comments  路  Source: joomla/joomla-cms

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?

No Code Attached Yet RFC

Most helpful comment

Does this answer your question: https://github.com/joomla/joomla-cms/pull/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

All 7 comments

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

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.

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

@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.

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.

Does this answer your question: https://github.com/joomla/joomla-cms/pull/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

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.
  1. 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).
Was this page helpful?
0 / 5 - 0 ratings