Problem/Motivation
There are still functional tests that can be converted, entirely or partially into Kernel/Unit tests.
Functional tests (aka Browser tests) install a complete Drupal site, using a virtual browser. This makes them slow to run.
In many cases, the same functionality could be tested in a kernel test. These are much quicker to run.
Quicker tests mean:
- better DX when developers run tests manually
- lower carbon footprint for drupal.org and any other organisations running Drupal's tests
- cheaper running costs for Drupal's CI
- quicker results for developers' merge requests and patches
Proposed resolution
Identify them and convert them:
Discovered so far:
- #3042994: MailCaptureTest provides the same test coverage as AssertMailTraitTest and should be removed
- #2695221: Remove ConfigFileContentTest and spread its ashes over ConfigCRUDTest and ConfigStorageTestBase
- #3046682: Convert BlockContentValidationTest into a Kernel test
- #2035133: Convert system module's Mail unit test to phpunit (duplicate #3049866: Convert HtmlToTextTest into a Unit test?)
- #3050353: \Drupal\Tests\system\Functional\Module\VersionTest could be a Kernel (or Unit) Test
- #2349453: Move \Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest::testTimezoneFormat into a Kernel test
Done:
- #2664292: Convert Module\InstallTest into a Kernel test
- #3305509: Convert LoadMultipleTest into a kernel test
- #3452511: convert ProviderRepositoryTest to a kernel test
- #3452513: convert FieldEntityTest to a kernel test
- #3454092: Convert WebAssertTest to a Unit test
- #3041755: Convert HandlerAllTest into a kernel test
- #3050172: Move MigrateLanguageTest under Kernel tests namespace
- #3049685: Move MigrateNodeRevisionTest & NodeMigrateDeriverTest under the Kernel tests namespace
- #3048434: Convert FileManagedAccessTest into a Kernel test
- #3046694: Convert BookInstallTest into a Kernel test
- #3049604: Convert CommentFieldNameTest into a Kernel test
- #3041842: Convert ArgumentValidateTest into a kernel test
- #3046937: Convert TrackerUserUidTest into a Kernel test. Deprecate TrackerTestBase
- #3041863: Convert a few node access tests from functional to kernel tests
- #3041030: Convert functional EfqTest to a kernel test and move TaxonomyTestTrait from tests/src/Functional to tests/src/Traits
- #3046018: Convert SelectionTest into a Kernel test
- #3046377: Convert ContactFieldsTest into a Kernel test
- #3041696: Convert FieldApiDataTest into a kernel test
- #3046382: Convert ConfigTranslationFormTest into a Kernel test
- #3041778: Convert FilterEntityBundleTest into a kernel test
- #3046388: Convert LocaleStringTest into a Kernel test
- #3046171: Convert FilterCaptionTwigDebugTest into a Kernel test
- #3046698: Convert BcRoutesTest into a Kernel test
- #3046676: Convert block_content RevisionRelationshipsTest into a Kernel test
- #3046393: Convert ConnectionFailureTest into a Kernel test
- #2432647: Convert BlockTemplateSuggestionsTest into a KernelTestBase
- #3046281: Convert FilterUidRevisionTest into a Kernel test
- #3046392: Convert LocaleLibraryAlterTest into a Kernel test
- #3039378: Convert TermEntityReferenceTest to be a kernel test
- #2079647: Convert UserSaveTest to a kernel test. Remove useless test
- #3041036: Convert UserDeleteTest to kernel test (or get rid of it?)
- #3041096: Convert FilterNoFormatTest to a kernel test
- #3041042: Convert UserEntityCallbacksTest to a kernel test
- #3041727: Convert ViewRenderTest into a Kernel test
- #3041743: Convert ViewsTemplateTest into a Kernel test
- #3041765: Convert FieldGroupRowsTest into a Kernel test
- #3041770: Convert ArgumentStringTest into a Kernel test
- #3041786: Convert LatestRevisionFilterTest to a kernel test
- #3041801: Convert StyleTest to a kernel test
- #3041816: Move UserMailNotifyTest under Kernel tests namespace
- #3042472: Convert HandlerArgumentUserUidTest into a kernel test and clean up the surrounding code
- #3042540: Convert user RelationshipRepresentativeNodeTest into a kernel test
- #3042869: Convert UpdateDeleteFileIfStaleTest into a Kernel test
- #3042640: Convert TaxonomyFieldTidTest to a kernel test
- #3042877: Convert ArgumentValidatorTermTest into a Kernel test
- #3041081: Convert ConfigEntityImportTest to a kernel test
- #3041779: Convert LatestTranslationAffectedRevisionTest into a kernel test
- #3042536: Convert AccessPermissionTest into a Kernel test
- #3042538: Convert ArgumentDefaultTest into a kernel test
- #3042875: Convert TaxonomyIndexTidFilterTest into a Kernel test
- #3041055: Convert TaxonomyQueryAlterTest to a kernel test
- #3041837: Convert UserDataTest into a kernel test
- #2473681: Convert VocabularyCrudTest test to kernel test
- #3046680: Convert NewDefaultThemeBlocksTest into a Kernel test
- #3049637: Convert CommentUninstallTest into a Kernel test
- #3041790: Convert ViewsSqlExceptionTest to a kernel test
- #3049612: Merge ArgumentUserUIDTest & FilterUserUIDTest and convert them into a Kernel test
- #3046723: Convert HandlerFieldFieldTest into a Kernel test
- #3028712: Convert system MailTest into a Kernel test. Break its simpletest dependency
- #3035518: Convert ImageEffectsTest & ToolkitTest into Kernel tests
- #3048423: Convert RelationshipUserFileDataTest into a Kernel test
- #2742997: Convert CommentActionsTest to kernel test
Won't fix:
- #3041813: Convert CacheTagTest into a kernel test
- #3045736: Convert ModuleInstallBatchTest into a Kernel test
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #85 | 3041700-strict-btb-tests.patch | 6.85 KB | longwave |
Comments
Comment #2
claudiu.cristeaI use this script to discover such tests:
The script should run with
drush scr.It detects a lot of tests that are not to be converted. But still helps. To be improved.
Comment #3
claudiu.cristeaAdded #3041727: Convert ViewRenderTest into a Kernel test
Comment #4
claudiu.cristeaAdded #3041743: Convert ViewsTemplateTest into a Kernel test.
Comment #5
claudiu.cristeaAdded #3041755: Convert HandlerAllTest into a kernel test.
Comment #6
claudiu.cristeaAdded #3041765: Convert FieldGroupRowsTest into a Kernel test.
Comment #7
claudiu.cristeaAdded #3041770: Convert ArgumentStringTest into a Kernel test.
Comment #8
claudiu.cristeaAdded #3041778: Convert FilterEntityBundleTest into a kernel test.
Comment #9
claudiu.cristeaAdded #3041779: Convert LatestTranslationAffectedRevisionTest into a kernel test.
Comment #10
claudiu.cristeaAdded #3041786: Convert LatestRevisionFilterTest to a kernel test.
Comment #11
claudiu.cristeaAdded #3041790: Convert ViewsSqlExceptionTest to a kernel test.
Comment #12
claudiu.cristeaAdded #3041801: Convert StyleTest to a kernel test.
Comment #13
claudiu.cristeaAdded #3041816: Move UserMailNotifyTest under Kernel tests namespace.
Comment #14
claudiu.cristeaAdded #3041837: Convert UserDataTest into a kernel test.
Comment #15
amateescu commentedAdded #3041863: Convert a few node access tests from functional to kernel tests.
Comment #16
claudiu.cristeaAdded #3042472: Convert HandlerArgumentUserUidTest into a kernel test and clean up the surrounding code.
Comment #17
claudiu.cristeaAdded #3042536: Convert AccessPermissionTest into a Kernel test.
Comment #18
claudiu.cristeaAdded #3042538: Convert ArgumentDefaultTest into a kernel test.
Comment #19
claudiu.cristeaAdded #3042540: Convert user RelationshipRepresentativeNodeTest into a kernel test.
Comment #20
claudiu.cristeaAdded #3042869: Convert UpdateDeleteFileIfStaleTest into a Kernel test.
Comment #21
claudiu.cristeaAdded #3042872: Convert TaxonomyFieldTidTest into a Kernel test.
Comment #22
claudiu.cristeaComment #23
claudiu.cristeaAdded #3042875: Convert TaxonomyIndexTidFilterTest into a Kernel test.
Comment #24
claudiu.cristeaAdded #3042877: Convert ArgumentValidatorTermTest into a Kernel test.
Comment #25
claudiu.cristeaComment #26
claudiu.cristeaAdded #3042994: MailCaptureTest provides the same test coverage as AssertMailTraitTest and should be removed.
Comment #27
mile23New child: #2432647: Convert BlockTemplateSuggestionsTest into a KernelTestBase
Comment #28
mile23New child: #2664292: Convert Module\InstallTest into a Kernel test
Comment #29
feuerwagenMoved fixed issues to separate list.
Comment #30
claudiu.cristeaMoved fixed issues to Done.
Comment #31
claudiu.cristeaComment #32
claudiu.cristeaAdded #3045736: Convert ModuleInstallBatchTest into a Kernel test.
Comment #33
mile23New child: #2473681: Convert VocabularyCrudTest test to kernel test
Comment #34
claudiu.cristeaAdded #3046018: Convert SelectionTest into a Kernel test.
Comment #35
claudiu.cristeaComment #36
claudiu.cristeaAdded #3046171: Convert FilterCaptionTwigDebugTest into a Kernel test.
Comment #37
mile23New child with poetic name: #2695221: Remove ConfigFileContentTest and spread its ashes over ConfigCRUDTest and ConfigStorageTestBase
Comment #38
claudiu.cristeaAdded #3046281: Convert FilterUidRevisionTest into a Kernel test.
Comment #39
claudiu.cristeaAdded #3046377: Convert ContactFieldsTest into a Kernel test.
Comment #40
claudiu.cristeaAdded #3046382: Convert ConfigTranslationFormTest into a Kernel test.
Comment #41
claudiu.cristeaAdded #3046388: Convert LocaleStringTest into a Kernel test.
Comment #42
claudiu.cristeaAdded #3046392: Convert LocaleLibraryAlterTest into a Kernel test.
Comment #43
claudiu.cristeaAdded #3046393: Convert ConnectionFailureTest into a Kernel test.
Comment #44
claudiu.cristeaAdded #3046670: Move block content creation methods to a trait.
Comment #45
claudiu.cristeaComment #46
claudiu.cristeaAdded #3046676: Convert block_content RevisionRelationshipsTest into a Kernel test.
Comment #47
claudiu.cristeaAdded #3046680: Convert NewDefaultThemeBlocksTest into a Kernel test.
Comment #48
claudiu.cristeaAdded #3046682: Convert BlockContentValidationTest into a Kernel test.
Comment #49
claudiu.cristeaAdded #3046694: Convert BookInstallTest into a Kernel test.
Comment #50
claudiu.cristeaAdded #3046698: Convert BcRoutesTest into a Kernel test.
Comment #51
claudiu.cristeaAdded #3046723: Convert HandlerFieldFieldTest into a Kernel test.
Comment #52
claudiu.cristeaAdded #3046937: Convert TrackerUserUidTest into a Kernel test. Deprecate TrackerTestBase.
Comment #53
phenaproximaUpdating the IS to reflect some recent commits. :)
Comment #54
naveenvalechaAdded #3041813: Convert CacheTagTest into a kernel test
Comment #55
claudiu.cristeaComment #56
claudiu.cristeaComment #57
claudiu.cristeaAdded #3048423: Convert RelationshipUserFileDataTest into a Kernel test.
Comment #58
claudiu.cristeaComment #59
claudiu.cristeaAdded #3048434: Convert FileManagedAccessTest into a Kernel test.
Comment #60
claudiu.cristeaComment #61
claudiu.cristeaComment #62
claudiu.cristeaAdded #3049604: Convert CommentFieldNameTest into a Kernel test.
Comment #63
claudiu.cristeaAdded #3049612: Merge ArgumentUserUIDTest & FilterUserUIDTest and convert them into a Kernel test.
Comment #64
claudiu.cristeaAdded #3049637: Convert CommentUninstallTest into a Kernel test.
Comment #65
claudiu.cristeaComment #66
claudiu.cristeaAdded #3049685: Move MigrateNodeRevisionTest & NodeMigrateDeriverTest under the Kernel tests namespace.
Comment #67
claudiu.cristeaAdded #3049866: Convert HtmlToTextTest into a Unit test.
Comment #68
claudiu.cristeaAdded #3028712: Convert system MailTest into a Kernel test. Break its simpletest dependency.
Comment #69
claudiu.cristeaAdding #2035133: Convert system module's Mail unit test to phpunit. Seems that #3049866: Convert HtmlToTextTest into a Unit test is a duplicate.
Comment #70
claudiu.cristeaAdded #3050172: Move MigrateLanguageTest under Kernel tests namespace.
Comment #71
claudiu.cristeaAdded #3050353: \Drupal\Tests\system\Functional\Module\VersionTest could be a Kernel (or Unit) Test.
Comment #72
naveenvalechaUpdated IS. Moved the #3041842: Convert ArgumentValidateTest into a kernel test #3046937: Convert TrackerUserUidTest into a Kernel test. Deprecate TrackerTestBase to Done.
Comment #73
naveenvalechaUpdated IS
Comment #74
feuerwagenMore issues are done.
Comment #75
claudiu.cristeaMore issues are fixed.
Comment #76
feuerwagenGetting there
Comment #77
manuel garcia commented#3028712: Convert system MailTest into a Kernel test. Break its simpletest dependency got in :)
Comment #78
manuel garcia commentedWas about to open a new one for
DrupalDateTimeTestbut it ends up there's already an issue for it, so adding it to the list here: #2349453: Move \Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest::testTimezoneFormat into a Kernel testComment #79
krzysztof domańskiI added to issue summary #2742997: Convert CommentActionsTest to kernel test.
Comment #83
joachim commentedI think there's a lot of functional tests that make browser requests as part of setting up content types, fields and so on. Those could be converted to API calls.
I've added #3211229: Add an API-based equivalent to FieldUiTestTrait with similar methods as a child issue; I'll try to find time to create issues for tests where this can be converted.
Comment #84
longwaveWhile looking at #3048423: Convert RelationshipUserFileDataTest into a Kernel test I wondered if we can mark BTB tests as "risky" or similar if e.g. they do not perform a drupalGet(). This won't catch everything that strictly doesn't need it but that one and #2349453: Move \Drupal\Tests\system\Functional\Datetime\DrupalDateTimeTest::testTimezoneFormat into a Kernel test for starters would be picked up.
Comment #85
longwaveA test patch for #84, this causes functional tests that do not perform HTTP requests to fail.
Comment #89
joachim commentedAdded issue summary from a duplicate I accidentally created today, & related issue for doing setup with API calls.
Comment #90
joachim commentedComment #91
claudiu.cristeaUpdating IS to account that #3035518: Convert ImageEffectsTest & ToolkitTest into Kernel tests, #3048423: Convert RelationshipUserFileDataTest into a Kernel test and #2742997: Convert CommentActionsTest to kernel test are fixed.
Comment #92
joachim commentedComment #95
mglamanI have stopped writing Functional tests and always use Kernel tests.
Here’s a bunch of examples I’ve done: https://git.drupalcode.org/project/google_tag/-/tree/2.0.x/tests/src/Ker...
It handles requests by passing it to the HTTP kernel. The above even tests user register and login.
That code is based on a personal library I use: https://github.com/mglaman/drupal-test-helpers
Comment #96
joachim commentedComment #97
joachim commentedFound a few more.
Sniff: calling $container->set() in a browser test is a dead giveaway -- it will have no effect on the SUT since that is getting the service container from cache or building it from YAML files!
Comment #98
catchComment #99
catchComment #100
catchFormElementsLabelTest is a potential candidate here - at least the last method does not http requests.
Comment #101
quietone commented