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
Comment #1
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedComment #2
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedComment #3
Crell CreditAttribution: Crell at Palantir.net commentedWhy 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).
Comment #4
Wim Leers+1
Comment #5
dawehnerThank 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.
Comment #6
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedWell, in the end everything in unit tests ends up in assertions and class construction is comparatively heavy on performance.
Comment #7
Crell CreditAttribution: Crell at Palantir.net commentedClass instantiation itself isn't that heavy. It depends very heavily on the dependencies the class has.
Comment #8
dawehnerI agree though that asserts are sort of a pain to debug in PHPUnit
Comment #9
dawehnerSo does anyone actually care about it? I don't see an issue in phpunit itself.
Comment #11
Mile23So what we ended up doing was making everything a trait. Does that satisfy this issue? :-)
Comment #12
dawehner@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.
Comment #22
quietone CreditAttribution: quietone at PreviousNext commentedThere 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.