Problem/Motivation

There are several Migration Kernel test files that run setup twice but do not need to. The only difference in the tests are the assertions run after the migration. There is no need to do the setup more than once. The migration can be run once and then all the assertions

This was already done in #3165763: Combine two tests to one in d7 MigrateFieldTest and MigrateFieldInstance. This issue does the same for the other migration tests, of which there are 10.

Also, an annoyance factor when working with those tests.

Proposed resolution

Combine the assertions

Remaining tasks

Patch
Review
Commit

Issue fork drupal-3192900

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone created an issue. See original summary.

quietone’s picture

Status: Active » Needs review
Issue tags: +Novice
FileSize
9.6 KB

Assuming this passes test, the review here is straightforward and suitable for a novice.

quietone’s picture

As soon as I uploaded I realized I hadn't run commit-code-check.

quietone’s picture

Priority: Normal » Minor

Matroskeen made their first commit to this issue’s fork.

Matroskeen’s picture

Status: Needs review » Needs work

The patch needed a re-roll after #2867959: Replace usages of deprecated AssertLegacyTrait::assertIdentical, so I created a merge request based on patch #3.

I prepared some numbers to see why these changes are good:
core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
Before the patch: 1.12 minutes
After: 33.21 seconds

core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php
Before the patch: 59.59 seconds
After: 34.75 seconds

I reviewed other similar migrations and I think it might be possible to optimize at least some of these:

  • core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeComplete.php
  • core/modules/language/tests/src/Kernel/Migrate/d6/MigrateLanguageContentSettingsTest.php
  • core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureD6FileTest.php

Moving to NW for that.

Matroskeen’s picture

quietone’s picture

Thanks for putting some numbers on this. It is nice to see the improvement.

I am not surprised there are more. I count 31 migrate kernel tests with more that one test method.

quietone’s picture

Status: Needs work » Needs review
Matroskeen’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, thanks!

quietone’s picture

Issue summary: View changes

Your welcome.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 82c63a2 and pushed to 9.2.x. Thanks!

  • alexpott committed 82c63a2 on 9.2.x
    Issue #3192900 by quietone, Matroskeen: Combine some migration kernel...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.