John Davidson

php - Drupal PHPUnit tests taking more than a day to execute

0 comments
Message:


I'm currently building Drupal inside a container, enabling the modules(using drush) and running testcases for the modules. I have ran the testcases for module facets using the vendor/phpunit cli command but its taking more than 30 hours for me. Any idea why its taking so much time?


bash-4.4# ../vendor/phpunit/phpunit/phpunit ../modules/facets/tests/src/
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.

Warning: Your XML configuration validates against a deprecated schema.
Suggestion: Migrate your XML configuration using "--migrate-configuration"!

Testing /home/server/drupal/modules/facets/tests/src
EEEEEEE.EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 63 / 332 ( 18%)
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.... 126 / 332 ( 37%)
......................E........................................ 189 / 332 ( 56%)
............................................................... 252 / 332 ( 75%)
............................................................... 315 / 332 ( 94%)
................. 332 / 332 (100%)


Time: 31:58:29.066, Memory: 30.00 MB

PS: I tried testing using the simpletest module, but its only testing 80 testcases(instead of 332 as above). Also, I want to use the cli for my work, not gui



My Answer:
There could be several reasons why your PHPUnit tests are taking so long to execute. Here are a few things you can check to try and improve the performance:

1. Check for inefficient test code: Make sure that your test code is written efficiently and does not contain any unnecessary loops or operations that could be slowing down the tests.

2. Check for large datasets: If your tests are using large datasets, consider reducing the size of the data being used in the tests to improve performance.

3. Check for dependencies: Make sure that your tests are not dependent on external services or resources that could be causing delays in the test execution.

4. Check for resource constraints: Make sure that your container has enough resources allocated to it (such as CPU and memory) to run the tests efficiently.

5. Consider parallel testing: If possible, consider running your tests in parallel to speed up the execution time.

6. Check for database queries: If your tests are making a lot of database queries, consider optimizing the queries or using a tool like PHPUnit's database testing features to improve performance.

By investigating these potential issues, you should be able to identify the root cause of the slow test execution and take steps to improve the performance of your PHPUnit tests.

Rate this post

3 of 5 based on 3091 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us