Follow-up to #2304461: KernelTestBaseTNG™

Problem/Motivation

PHPUnit is not easily debuggable right now due to a quite complicated assert() structure.

Example assertNotNull (!== NULL) goes via three classes (#2469731-5: Document when to use BrowserTestBase).

That is bad for performance and bad for debuggability.

With Drupal wanting to use PHPUnit for everything, performance is again important and debuggability is important for DX.

Proposed resolution

- Have all UnitTestCase, BrowserTestBase, KernelTestBase (NG) derive from own common class e.g. CommonTestBase instead of \PHPUnit_Framework_TestCase.
- Provide our own implementations of assert*() functions
- Test performance (and hopefully it is faster)
- Profit!

=> Contribute back upstream

Remaining tasks

- Discuss
- Do it

User interface changes

- None

API changes

- None, Test only changes (unfrozen)

Comments

Fabianx’s picture

Issue summary: View changes
Fabianx’s picture

Title: Improve PHPUnit debuggability » Improve PHPUnit debuggability and performance
Crell’s picture

Why not just work upstream and help make PHPUnit faster? Either there's some good reason why it's as abstracted as it is (in which case we probably want to keep it) or it could legitimately be simpler (in which case we should work upstream and help out all of the PHPUnit-using world).

Wim Leers’s picture

+1

dawehner’s picture

Thank you fabian for not derailing the other issue.

What I care about is that we don't bypass the tool support for PHPUnit, which means for example that IDEs can print out the difference between variables in a nice way.
In general I doubt that you you can really measure the performance impact given that the amount of assertions is not high compared to test methods, which have probably some higher setup cost, both for unit tests and more specially for kernel or browser tests.

Fabianx’s picture

Well, in the end everything in unit tests ends up in assertions and class construction is comparatively heavy on performance.

Crell’s picture

Class instantiation itself isn't that heavy. It depends very heavily on the dependencies the class has.

dawehner’s picture

I agree though that asserts are sort of a pain to debug in PHPUnit

dawehner’s picture

So does anyone actually care about it? I don't see an issue in phpunit itself.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Status: Needs review » Postponed (maintainer needs more info)

So what we ended up doing was making everything a trait. Does that satisfy this issue? :-)

dawehner’s picture

@Mile23
The original authors wanted to replace basically all basic assertions with a Drupal only solution. This wasn't done, and well, I argue this was mostly an issue to put some general frustration down, which is fine.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

There has been no activity here for 5 years.

The last two comments suggest that there is nothing further to do here. Therefor, closing as works as desgined. If this is incorrect reopen the issue, by setting the status to 'Active', and add a comment explaining what still needs to be done.

Thanks.