From b7627bcae46b6fd98c71dd95b93a76ca07c72fa8 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Tue, 14 Jul 2020 10:58:42 +0100
Subject: [PATCH] Issue #3123120 by mondrake, ridhimaabrol24, longwave:
 Properly deprecate AssertLegacyTrait::pass

---
 .../tests/src/Functional/BigPipeTest.php      | 26 ++++----
 .../tests/src/Kernel/BlockViewBuilderTest.php |  3 -
 .../Functional/BlockContentCreationTest.php   |  2 +-
 .../BlockContentTranslationUITest.php         |  4 +-
 .../Migrate/MigrateBlockContentStubTest.php   | 13 ++--
 .../tests/src/Functional/CommentPagerTest.php |  1 -
 .../tests/src/Functional/CommentTypeTest.php  |  2 +-
 .../Kernel/CommentStringIdEntitiesTest.php    | 39 ++++++------
 .../tests/src/Functional/ConfigEntityTest.php | 20 ++-----
 .../SchemaConfigListenerWebTest.php           | 12 +---
 .../src/Functional/EditorSecurityTest.php     | 11 ----
 .../Kernel/EditorFileReferenceFilterTest.php  | 16 ++---
 ...qlContentEntityStorageSchemaColumnTest.php | 13 ++--
 .../EntityReferenceItemTest.php               |  4 +-
 .../field/tests/src/Kernel/FieldCrudTest.php  |  4 +-
 .../Kernel/FieldDefinitionIntegrityTest.php   | 29 ++-------
 .../tests/src/Kernel/FieldStorageCrudTest.php | 41 +++++++------
 .../tests/src/Functional/FilterFormTest.php   |  4 --
 .../hal/tests/src/Kernel/DenormalizeTest.php  |  4 +-
 .../Migrate/d6/MigrateImageCacheTest.php      | 15 ++---
 .../LanguageDependencyInjectionTest.php       |  2 +-
 .../src/Kernel/EditorMediaDialogTest.php      |  4 +-
 .../src/Functional/MenuCacheTagsTest.php      |  5 --
 .../NodeAccessGrantsCacheContextTest.php      |  1 -
 .../tests/src/Functional/NodeCreationTest.php |  2 +-
 .../src/Functional/Views/BulkFormTest.php     |  4 --
 .../src/Functional/Views/FrontPageTest.php    |  2 -
 .../tests/src/Kernel/OptionsFieldTest.php     |  2 +-
 .../src/Functional/GetRdfNamespacesTest.php   |  2 +-
 .../tests/src/Kernel/SerializationTest.php    |  2 +-
 .../tests/src/Functional/Common/UrlTest.php   |  1 -
 .../src/Functional/Mail/HtmlToTextTest.php    |  5 +-
 .../src/Functional/Menu/LocalTasksTest.php    |  8 +--
 .../src/Functional/Module/InstallTest.php     |  8 +--
 .../src/Functional/Module/UninstallTest.php   |  2 +-
 .../src/Functional/Routing/RouterTest.php     |  2 +-
 .../Functional/System/SiteMaintenanceTest.php |  1 -
 .../src/Kernel/Common/PageRenderTest.php      |  2 -
 .../Kernel/Extension/ModuleHandlerTest.php    |  6 +-
 .../Functional/ToolbarCacheContextsTest.php   |  7 +--
 .../src/Functional/TourCacheTagsTest.php      |  2 -
 .../src/Kernel/RenderCacheIntegrationTest.php | 15 +----
 .../src/Kernel/ViewsConfigUpdaterTest.php     |  3 +-
 .../src/Functional/DemoUmamiProfileTest.php   |  1 -
 .../Bootstrap/UncaughtExceptionTest.php       |  3 +-
 .../FunctionalTests/BrowserTestBaseTest.php   | 54 ++++++++---------
 ...istributionProfileExistingSettingsTest.php |  1 -
 .../MultipleDistributionsProfileTest.php      |  1 -
 .../KernelTests/Config/DefaultConfigTest.php  |  5 +-
 .../Asset/LibraryDiscoveryIntegrationTest.php |  7 +--
 .../KernelTests/Core/Command/DbDumpTest.php   | 24 +-------
 .../Core/Config/ConfigCRUDTest.php            | 40 +++++--------
 .../Core/Config/ConfigEntityStorageTest.php   |  3 +-
 .../Core/Config/ConfigExportStorageTest.php   |  9 +--
 .../ConfigImportRenameValidationTest.php      |  2 -
 .../Core/Config/ConfigImporterTest.php        | 13 ++--
 .../Core/Config/ConfigSchemaTest.php          | 12 +---
 .../Core/Config/Storage/FileStorageTest.php   |  1 -
 .../Core/Database/ConnectionTest.php          | 24 ++------
 .../Database/DatabaseExceptionWrapperTest.php | 21 +------
 .../Core/Database/InsertDefaultsTest.php      |  2 +-
 .../KernelTests/Core/Database/MergeTest.php   |  9 +--
 .../KernelTests/Core/Database/QueryTest.php   | 12 ++--
 .../KernelTests/Core/Database/SchemaTest.php  |  8 +--
 .../KernelTests/Core/Database/SelectTest.php  | 11 ++--
 .../Core/Database/TransactionTest.php         | 36 +++++------
 .../Core/DrupalKernel/DrupalKernelTest.php    |  5 +-
 .../KernelTests/Core/Entity/EntityApiTest.php |  2 -
 .../Core/Entity/EntityAutocompleteTest.php    |  9 +--
 .../Core/Entity/EntityCrudHookTest.php        |  2 +-
 .../Entity/EntityDefinitionUpdateTest.php     | 20 +++----
 .../Core/Entity/EntityQueryTest.php           | 17 ++----
 .../Core/Entity/EntityReferenceFieldTest.php  |  7 +--
 .../Core/Entity/EntityTranslationTest.php     | 60 +++++++------------
 .../Core/Entity/FieldSqlStorageTest.php       | 11 +---
 .../Extension/ModuleImplementsAlterTest.php   | 13 ++--
 .../KeyValueContentEntityStorageTest.php      |  9 ++-
 .../Core/Menu/MenuTreeStorageTest.php         |  3 +-
 .../KernelTests/Core/Plugin/FactoryTest.php   | 10 +---
 .../KernelTests/Core/Render/RenderTest.php    |  9 +--
 .../Routing/ContentNegotiationRoutingTest.php |  6 +-
 .../Core/Routing/MatcherDumperTest.php        | 10 +---
 .../Core/Session/AccountSwitcherTest.php      | 15 +----
 .../Core/Theme/ThemeInstallerTest.php         | 28 ++++-----
 .../Core/TypedData/TypedDataTest.php          |  6 +-
 .../Core/Assert/AssertLegacyTraitTest.php     |  8 +++
 .../Listeners/DeprecationListenerTrait.php    |  1 -
 87 files changed, 307 insertions(+), 594 deletions(-)

diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
index a4983fded980..92efb10376d0 100644
--- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
+++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
@@ -186,7 +186,7 @@ public function testBigPipe() {
 
     $this->assertRaw('</body>', 'Closing body tag present.');
 
-    $this->pass('Verifying BigPipe assets are present…', 'Debug');
+    // Verifying BigPipe assets are present.
     $this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.');
     $this->assertContains('big_pipe/big_pipe', explode(',', $this->getDrupalSettings()['ajaxPageState']['libraries']), 'BigPipe asset library is present.');
 
@@ -205,7 +205,8 @@ public function testBigPipe() {
     $this->drupalGet(Url::fromUri('base:non-existing-path'));
 
     // Simulate development.
-    $this->pass('Verifying BigPipe provides useful error output when an error occurs while rendering a placeholder if verbose error logging is enabled.', 'Debug');
+    // Verifying BigPipe provides useful error output when an error occurs
+    // while rendering a placeholder if verbose error logging is enabled.
     $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
     $this->drupalGet(Url::fromRoute('big_pipe_test'));
     // The 'edge_case__html_exception' case throws an exception.
@@ -259,13 +260,13 @@ public function testBigPipeNoJs() {
       $cases['exception__embedded_response']->bigPipePlaceholderId        => NULL,
     ]);
 
-    $this->pass('Verifying there are no BigPipe placeholders & replacements…', 'Debug');
+    // Verifying there are no BigPipe placeholders & replacements.
     $this->assertEqual('<none>', $this->drupalGetHeader('BigPipe-Test-Placeholders'));
-    $this->pass('Verifying BigPipe start/stop signals are absent…', 'Debug');
+    // Verifying BigPipe start/stop signals are absent.
     $this->assertNoRaw(BigPipe::START_SIGNAL, 'BigPipe start signal absent.');
     $this->assertNoRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal absent.');
 
-    $this->pass('Verifying BigPipe assets are absent…', 'Debug');
+    // Verifying BigPipe assets are absent.
     $this->assertTrue(!isset($this->getDrupalSettings()['bigPipePlaceholderIds']) && empty($this->getDrupalSettings()['ajaxPageState']), 'BigPipe drupalSettings and BigPipe asset library absent.');
     $this->assertRaw('</body>', 'Closing body tag present.');
 
@@ -274,7 +275,8 @@ public function testBigPipeNoJs() {
     $this->drupalGet(Url::fromUri('base:non-existing-path'));
 
     // Simulate development.
-    $this->pass('Verifying BigPipe provides useful error output when an error occurs while rendering a placeholder if verbose error logging is enabled.', 'Debug');
+    // Verifying BigPipe provides useful error output when an error occurs
+    // while rendering a placeholder if verbose error logging is enabled.
     $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
     $this->drupalGet(Url::fromRoute('big_pipe_test'));
     // The 'edge_case__html_exception' case throws an exception.
@@ -322,7 +324,6 @@ public function testBigPipeMultiOccurrencePlaceholders() {
   }
 
   protected function assertBigPipeResponseHeadersPresent() {
-    $this->pass('Verifying BigPipe response headers…', 'Debug');
     // Check that Cache-Control header set to "private".
     $this->assertSession()->responseHeaderContains('Cache-Control', 'private');
     $this->assertEqual('no-store, content="BigPipe/1.0"', $this->drupalGetHeader('Surrogate-Control'));
@@ -337,10 +338,10 @@ protected function assertBigPipeResponseHeadersPresent() {
    *   markup.
    */
   protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_placeholders) {
-    $this->pass('Verifying BigPipe no-JS placeholders & replacements…', 'Debug');
     $this->assertSetsEqual(array_keys($expected_big_pipe_nojs_placeholders), array_map('rawurldecode', explode(' ', $this->drupalGetHeader('BigPipe-Test-No-Js-Placeholders'))));
     foreach ($expected_big_pipe_nojs_placeholders as $big_pipe_nojs_placeholder => $expected_replacement) {
-      $this->pass('Checking whether the replacement for the BigPipe no-JS placeholder "' . $big_pipe_nojs_placeholder . '" is present:');
+      // Checking whether the replacement for the BigPipe no-JS placeholder
+      // $big_pipe_nojs_placeholder is present.
       $this->assertNoRaw($big_pipe_nojs_placeholder);
       if ($expected_replacement !== NULL) {
         $this->assertRaw($expected_replacement);
@@ -358,12 +359,10 @@ protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_p
    *   defined in the order that they are expected to be rendered & streamed.
    */
   protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholders, array $expected_big_pipe_placeholder_stream_order) {
-    $this->pass('Verifying BigPipe placeholders & replacements…', 'Debug');
     $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders), explode(' ', $this->drupalGetHeader('BigPipe-Test-Placeholders')));
     $placeholder_positions = [];
     $placeholder_replacement_positions = [];
     foreach ($expected_big_pipe_placeholders as $big_pipe_placeholder_id => $expected_ajax_response) {
-      $this->pass('BigPipe placeholder: ' . $big_pipe_placeholder_id, 'Debug');
       // Verify expected placeholder.
       $expected_placeholder_html = '<span data-big-pipe-placeholder-id="' . $big_pipe_placeholder_id . '"></span>';
       $this->assertRaw($expected_placeholder_html, 'BigPipe placeholder for placeholder ID "' . $big_pipe_placeholder_id . '" found.');
@@ -396,14 +395,15 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
     $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders_with_replacements), array_values($placeholder_replacement_positions));
     $this->assertSame(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getSession()->getPage()->getContent()));
 
-    $this->pass('Verifying BigPipe start/stop signals…', 'Debug');
+    // Verifying BigPipe start/stop signals.
     $this->assertRaw(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
     $this->assertRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal present.');
     $start_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::START_SIGNAL);
     $stop_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::STOP_SIGNAL);
     $this->assertTrue($start_signal_position < $stop_signal_position, 'BigPipe start signal appears before stop signal.');
 
-    $this->pass('Verifying BigPipe placeholder replacements and start/stop signals were streamed in the correct order…', 'Debug');
+    // Verifying BigPipe placeholder replacements and start/stop signals were
+    // streamed in the correct order.
     $expected_stream_order = array_keys($expected_big_pipe_placeholders_with_replacements);
     array_unshift($expected_stream_order, BigPipe::START_SIGNAL);
     array_push($expected_stream_order, BigPipe::STOP_SIGNAL);
diff --git a/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php b/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php
index 056888677a41..70d7e1e152eb 100644
--- a/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php
+++ b/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php
@@ -292,7 +292,6 @@ protected function assertBlockRenderedWithExpectedCacheability(array $expected_k
 
     // Check that the expected cacheability metadata is present in:
     // - the built render array;
-    $this->pass('Built render array');
     $build = $this->getBlockRenderArray();
     $this->assertIdentical($expected_keys, $build['#cache']['keys']);
     $this->assertIdentical($expected_contexts, $build['#cache']['contexts']);
@@ -300,10 +299,8 @@ protected function assertBlockRenderedWithExpectedCacheability(array $expected_k
     $this->assertIdentical($expected_max_age, $build['#cache']['max-age']);
     $this->assertFalse(isset($build['#create_placeholder']));
     // - the rendered render array;
-    $this->pass('Rendered render array');
     $this->renderer->renderRoot($build);
     // - the render cache item.
-    $this->pass('Render cache item');
     $final_cache_contexts = Cache::mergeContexts($expected_contexts, $required_cache_contexts);
     $cid = implode(':', $expected_keys) . ':' . implode(':', \Drupal::service('cache_contexts_manager')->convertTokensToKeys($final_cache_contexts)->getKeys());
     $cache_item = $this->container->get('cache.render')->get($cid);
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
index 49d72b8f16e2..ad90ed095799 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
@@ -206,7 +206,7 @@ public function testFailedBlockCreation() {
       $this->fail('Expected exception has not been thrown.');
     }
     catch (\Exception $e) {
-      $this->pass('Expected exception has been thrown.');
+      // Expected exception; just continue testing.
     }
 
     $connection = Database::getConnection();
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
index 1f4693d4be36..9de7f8f983e1 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
@@ -118,12 +118,10 @@ protected function doTestBasicTranslation() {
     $entity->addTranslation('it', $values);
 
     try {
-      $message = 'Blocks can have translations with the same "info" value.';
       $entity->save();
-      $this->pass($message);
     }
     catch (\Exception $e) {
-      $this->fail($message);
+      $this->fail('Blocks can have translations with the same "info" value.');
     }
 
     // Check that the translate operation link is shown.
diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentStubTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentStubTest.php
index 3fef6b9ab5ca..d1766b41aa9a 100644
--- a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentStubTest.php
+++ b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentStubTest.php
@@ -33,15 +33,10 @@ protected function setUp(): void {
    * Tests creation of block content stubs with no block_content_type available.
    */
   public function testStubFailure() {
-    $message = 'Expected MigrateException thrown when no bundles exist.';
-    try {
-      $this->createEntityStub('block_content');
-      $this->fail($message);
-    }
-    catch (MigrateException $e) {
-      $this->pass($message);
-      $this->assertEqual('Stubbing failed, no bundles available for entity type: block_content', $e->getMessage());
-    }
+    // Expected MigrateException thrown when no bundles exist.
+    $this->expectException(MigrateException::class);
+    $this->expectExceptionMessage('Stubbing failed, no bundles available for entity type: block_content');
+    $this->createEntityStub('block_content');
   }
 
   /**
diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
index 25da658ad650..6e501a1f7f68 100644
--- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
@@ -429,7 +429,6 @@ protected function clickLinkWithXPath($xpath, $arguments = [], $index = 0) {
     $urls = $this->xpath($xpath, $arguments);
     if (isset($urls[$index])) {
       $url_target = $this->getAbsoluteUrl($urls[$index]->getAttribute('href'));
-      $this->pass(new FormattableMarkup('Clicked link %label (@url_target) from @url_before', ['%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before]), 'Browser');
       return $this->drupalGet($url_target);
     }
     $this->fail(new FormattableMarkup('Link %label does not exist on @url_before', ['%label' => $xpath, '@url_before' => $url_before]), 'Browser');
diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
index d13b9c629606..52dc7ce93792 100644
--- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
@@ -186,7 +186,7 @@ public function testCommentTypeDeletion() {
       $this->fail('Exception not thrown.');
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass('Exception thrown if attempting to re-use comment-type from another entity type.');
+      // Expected exception; just continue testing.
     }
 
     // Delete the comment type.
diff --git a/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php b/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php
index 79c434c16c58..817abbcd370c 100644
--- a/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php
+++ b/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php
@@ -40,28 +40,23 @@ protected function setUp(): void {
    * Tests that comment fields cannot be added entities with non-integer IDs.
    */
   public function testCommentFieldNonStringId() {
-    try {
-      $bundle = CommentType::create([
-        'id' => 'foo',
-        'label' => 'foo',
-        'description' => '',
-        'target_entity_type_id' => 'entity_test_string_id',
-      ]);
-      $bundle->save();
-      $field_storage = FieldStorageConfig::create([
-        'field_name' => 'foo',
-        'entity_type' => 'entity_test_string_id',
-        'settings' => [
-          'comment_type' => 'entity_test_string_id',
-        ],
-        'type' => 'comment',
-      ]);
-      $field_storage->save();
-      $this->fail('Did not throw an exception as expected.');
-    }
-    catch (\UnexpectedValueException $e) {
-      $this->pass('Exception thrown when trying to create comment field on Entity Type with string ID.');
-    }
+    $this->expectException(\UnexpectedValueException::class);
+    $bundle = CommentType::create([
+      'id' => 'foo',
+      'label' => 'foo',
+      'description' => '',
+      'target_entity_type_id' => 'entity_test_string_id',
+    ]);
+    $bundle->save();
+    $field_storage = FieldStorageConfig::create([
+      'field_name' => 'foo',
+      'entity_type' => 'entity_test_string_id',
+      'settings' => [
+        'comment_type' => 'entity_test_string_id',
+      ],
+      'type' => 'comment',
+    ]);
+    $field_storage->save();
   }
 
 }
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php
index 73101bc92128..6ba2467214e8 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php
@@ -69,7 +69,7 @@ public function testCRUD() {
       $this->fail('EntityMalformedException was thrown.');
     }
     catch (EntityMalformedException $e) {
-      $this->pass('EntityMalformedException was thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Verify that an empty entity cannot be saved.
@@ -78,7 +78,7 @@ public function testCRUD() {
       $this->fail('EntityMalformedException was thrown.');
     }
     catch (EntityMalformedException $e) {
-      $this->pass('EntityMalformedException was thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Verify that an entity with an empty ID string is considered empty, too.
@@ -91,7 +91,7 @@ public function testCRUD() {
       $this->fail('EntityMalformedException was thrown.');
     }
     catch (EntityMalformedException $e) {
-      $this->pass('EntityMalformedException was thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Verify properties on a newly created entity.
@@ -116,7 +116,6 @@ public function testCRUD() {
     // Verify that the entity can be saved.
     try {
       $status = $config_test->save();
-      $this->pass('EntityMalformedException was not thrown.');
     }
     catch (EntityMalformedException $e) {
       $this->fail('EntityMalformedException was not thrown.');
@@ -151,9 +150,6 @@ public function testCRUD() {
     ]);
     try {
       $id_length_config_test->save();
-      $this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
-        '@length' => strlen($id_length_config_test->id()),
-      ]));
     }
     catch (ConfigEntityIdLengthException $e) {
       $this->fail($e->getMessage());
@@ -165,9 +161,6 @@ public function testCRUD() {
     ]);
     try {
       $id_length_config_test->save();
-      $this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
-        '@length' => strlen($id_length_config_test->id()),
-      ]));
     }
     catch (ConfigEntityIdLengthException $e) {
       $this->fail($e->getMessage());
@@ -185,10 +178,7 @@ public function testCRUD() {
       ]));
     }
     catch (ConfigEntityIdLengthException $e) {
-      $this->pass(new FormattableMarkup("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [
-        '@length' => strlen($id_length_config_test->id()),
-        '@max' => static::MAX_ID_LENGTH,
-      ]));
+      // Expected exception; just continue testing.
     }
 
     // Ensure that creating an entity with the same id as an existing one is not
@@ -202,7 +192,7 @@ public function testCRUD() {
       $this->fail('Not possible to overwrite an entity entity.');
     }
     catch (EntityStorageException $e) {
-      $this->pass('Not possible to overwrite an entity entity.');
+      // Expected exception; just continue testing.
     }
 
     // Verify that renaming the ID returns correct status and properties.
diff --git a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php
index ecc1a7d174bf..6812c7db3972 100644
--- a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php
+++ b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php
@@ -29,38 +29,32 @@ public function testConfigSchemaChecker() {
     $this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
 
     // Test a non-existing schema.
-    $msg = 'Expected SchemaIncompleteException thrown';
     try {
       $this->config('config_schema_test.schemaless')->set('foo', 'bar')->save();
-      $this->fail($msg);
+      $this->fail('Expected SchemaIncompleteException thrown');
     }
     catch (SchemaIncompleteException $e) {
-      $this->pass($msg);
       $this->assertEquals('No schema for config_schema_test.schemaless', $e->getMessage());
     }
 
     // Test a valid schema.
-    $msg = 'Unexpected SchemaIncompleteException thrown';
     $config = $this->config('config_test.types')->set('int', 10);
     try {
       $config->save();
-      $this->pass($msg);
     }
     catch (SchemaIncompleteException $e) {
-      $this->fail($msg);
+      $this->fail('Unexpected SchemaIncompleteException thrown');
     }
 
     // Test an invalid schema.
-    $msg = 'Expected SchemaIncompleteException thrown';
     $config = $this->config('config_test.types')
       ->set('foo', 'bar')
       ->set('array', 1);
     try {
       $config->save();
-      $this->fail($msg);
+      $this->fail('Expected SchemaIncompleteException thrown');
     }
     catch (SchemaIncompleteException $e) {
-      $this->pass($msg);
       $this->assertEquals('Schema errors for config_test.types with the following errors: config_test.types:array variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence, config_test.types:foo missing schema', $e->getMessage());
     }
 
diff --git a/core/modules/editor/tests/src/Functional/EditorSecurityTest.php b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
index 38df20dd41c3..95b1ffc84f7f 100644
--- a/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
+++ b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\editor\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Serialization\Json;
 use Drupal\editor\Entity\Editor;
 use Drupal\filter\Entity\FilterFormat;
@@ -282,10 +281,6 @@ public function testInitialSecurity() {
     // Log in as each user that may edit the content, and assert the value.
     foreach ($expected as $case) {
       foreach ($case['users'] as $account) {
-        $this->pass(new FormattableMarkup('Scenario: sample %sample_id, %format.', [
-          '%sample_id' => $case['node_id'],
-          '%format' => $case['format'],
-        ]));
         $this->drupalLogin($account);
         $this->drupalGet('node/' . $case['node_id'] . '/edit');
         $dom_node = $this->xpath('//textarea[@id="edit-body-0-value"]');
@@ -407,12 +402,6 @@ public function testSwitchingSecurity() {
 
       // Switch to every other text format/editor and verify the results.
       foreach ($case['switch_to'] as $format => $expected_filtered_value) {
-        $this->pass(new FormattableMarkup('Scenario: sample %sample_id, switch from %original_format to %format.', [
-          '%sample_id' => $case['node_id'],
-          '%original_format' => $case['format'],
-          '%format' => $format,
-        ]));
-
         $post = [
           'value' => self::$sampleContent,
           'original_format_id' => $case['format'],
diff --git a/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php b/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php
index 5aeeef0f30c0..680466ed9338 100644
--- a/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php
+++ b/core/modules/editor/tests/src/Kernel/EditorFileReferenceFilterTest.php
@@ -71,44 +71,44 @@ public function testEditorFileReferenceFilter() {
     $uuid_2 = $image_2->uuid();
     $cache_tag_2 = ['file:' . $id_2];
 
-    $this->pass('No data-entity-type and no data-entity-uuid attribute.');
+    // No data-entity-type and no data-entity-uuid attribute.
     $input = '<img src="llama.jpg" />';
     $output = $test($input);
     $this->assertIdentical($input, $output->getProcessedText());
 
-    $this->pass('A non-file data-entity-type attribute value.');
+    // A non-file data-entity-type attribute value.
     $input = '<img src="llama.jpg" data-entity-type="invalid-entity-type-value" data-entity-uuid="' . $uuid . '" />';
     $output = $test($input);
     $this->assertIdentical($input, $output->getProcessedText());
 
-    $this->pass('One data-entity-uuid attribute.');
+    // One data-entity-uuid attribute.
     $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
     $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
     $output = $test($input);
     $this->assertIdentical($expected_output, $output->getProcessedText());
     $this->assertEqual($cache_tag, $output->getCacheTags());
 
-    $this->pass('One data-entity-uuid attribute with odd capitalization.');
+    // One data-entity-uuid attribute with odd capitalization.
     $input = '<img src="llama.jpg" data-entity-type="file" DATA-entity-UUID =   "' . $uuid . '" />';
     $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
     $output = $test($input);
     $this->assertIdentical($expected_output, $output->getProcessedText());
     $this->assertEqual($cache_tag, $output->getCacheTags());
 
-    $this->pass('One data-entity-uuid attribute on a non-image tag.');
+    // One data-entity-uuid attribute on a non-image tag.
     $input = '<video src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
     $expected_output = '<video src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '"></video>';
     $output = $test($input);
     $this->assertIdentical($expected_output, $output->getProcessedText());
     $this->assertEqual($cache_tag, $output->getCacheTags());
 
-    $this->pass('One data-entity-uuid attribute with an invalid value.');
+    // One data-entity-uuid attribute with an invalid value.
     $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="invalid-' . $uuid . '" />';
     $output = $test($input);
     $this->assertIdentical($input, $output->getProcessedText());
     $this->assertEqual([], $output->getCacheTags());
 
-    $this->pass('Two different data-entity-uuid attributes.');
+    // Two different data-entity-uuid attributes.
     $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
     $input .= '<img src="alpaca.jpg" data-entity-type="file" data-entity-uuid="' . $uuid_2 . '" />';
     $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
@@ -117,7 +117,7 @@ public function testEditorFileReferenceFilter() {
     $this->assertIdentical($expected_output, $output->getProcessedText());
     $this->assertEqual(Cache::mergeTags($cache_tag, $cache_tag_2), $output->getCacheTags());
 
-    $this->pass('Two identical  data-entity-uuid attributes.');
+    // Two identical  data-entity-uuid attributes.
     $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
     $input .= '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
     $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
diff --git a/core/modules/field/tests/src/Kernel/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php b/core/modules/field/tests/src/Kernel/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php
index d1e9fd24fd76..b8d0cc4a4d7d 100644
--- a/core/modules/field/tests/src/Kernel/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php
+++ b/core/modules/field/tests/src/Kernel/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php
@@ -90,15 +90,10 @@ public function testColumnUpdate() {
 
     // Now attempt to run automatic updates. An exception should be thrown
     // since there is data in the table.
-    try {
-      $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
-      $field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('test', 'entity_test_rev');
-      $entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
-      $this->fail('Failed to detect a schema change in a field with data.');
-    }
-    catch (FieldStorageDefinitionUpdateForbiddenException $e) {
-      $this->pass('Detected a schema change in a field with data.');
-    }
+    $this->expectException(FieldStorageDefinitionUpdateForbiddenException::class);
+    $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
+    $field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('test', 'entity_test_rev');
+    $entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
   }
 
 }
diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
index 78ad5d8e9511..f9ded30b21d3 100644
--- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
+++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
@@ -187,8 +187,8 @@ public function testContentEntityReferenceItem() {
       $entity->field_test_taxonomy_term = ['target_id' => 'invalid', 'entity' => $term2];
       $this->fail('Assigning an invalid item throws an exception.');
     }
-    catch (\InvalidArgumentException $e) {
-      $this->pass('Assigning an invalid item throws an exception.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
 
     // Delete terms so we have nothing to reference and try again
diff --git a/core/modules/field/tests/src/Kernel/FieldCrudTest.php b/core/modules/field/tests/src/Kernel/FieldCrudTest.php
index d964baadf646..dd40dcff59eb 100644
--- a/core/modules/field/tests/src/Kernel/FieldCrudTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldCrudTest.php
@@ -103,7 +103,7 @@ public function testCreateField() {
       $this->fail('Cannot create two fields with the same field / bundle combination.');
     }
     catch (EntityStorageException $e) {
-      $this->pass('Cannot create two fields with the same field / bundle combination.');
+      // Expected exception; just continue testing.
     }
 
     // Check that the specified field exists.
@@ -113,7 +113,7 @@ public function testCreateField() {
       $this->fail('Cannot create a field with a non-existing storage.');
     }
     catch (FieldException $e) {
-      $this->pass('Cannot create a field with a non-existing storage.');
+      // Expected exception; just continue testing.
     }
 
     // TODO: test other failures.
diff --git a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php
index c5ffe1b883f4..4db589230c87 100644
--- a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php
@@ -65,46 +65,25 @@ public function testFieldPluginDefinitionIntegrity() {
     foreach ($field_type_manager->getDefinitions() as $definition) {
       // Test default field widgets.
       if (isset($definition['default_widget'])) {
-        if (in_array($definition['default_widget'], $available_field_widget_ids)) {
-          $this->pass(sprintf('Field type %s uses an existing field widget by default.', $definition['id']));
-        }
-        else {
-          $this->fail(sprintf('Field type %s uses a non-existent field widget by default: %s', $definition['id'], $definition['default_widget']));
-        }
+        $this->assertContains($definition['default_widget'], $available_field_widget_ids, sprintf('Field type %s uses a non-existent field widget by default: %s', $definition['id'], $definition['default_widget']));
       }
 
       // Test default field formatters.
       if (isset($definition['default_formatter'])) {
-        if (in_array($definition['default_formatter'], $available_field_formatter_ids)) {
-          $this->pass(sprintf('Field type %s uses an existing field formatter by default.', $definition['id']));
-        }
-        else {
-          $this->fail(sprintf('Field type %s uses a non-existent field formatter by default: %s', $definition['id'], $definition['default_formatter']));
-        }
+        $this->assertContains($definition['default_formatter'], $available_field_formatter_ids, sprintf('Field type %s uses a non-existent field formatter by default: %s', $definition['id'], $definition['default_formatter']));
       }
     }
 
     // Test the field widget plugins.
     foreach ($field_widget_manager->getDefinitions() as $definition) {
       $missing_field_type_ids = array_diff($definition['field_types'], $available_field_type_ids);
-      if ($missing_field_type_ids) {
-        $this->fail(sprintf('Field widget %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
-      }
-      else {
-        $this->pass(sprintf('Field widget %s integrates with existing field types.', $definition['id']));
-      }
+      $this->assertEmpty($missing_field_type_ids, sprintf('Field widget %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
     }
 
     // Test the field formatter plugins.
     foreach ($field_formatter_manager->getDefinitions() as $definition) {
       $missing_field_type_ids = array_diff($definition['field_types'], $available_field_type_ids);
-      if ($missing_field_type_ids) {
-        $this->fail(sprintf('Field formatter %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
-      }
-      else {
-        $this->pass(sprintf('Field formatter %s integrates with existing field types.', $definition['id']));
-      }
-
+      $this->assertEmpty($missing_field_type_ids, sprintf('Field formatter %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
     }
   }
 
diff --git a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
index 3c40df22aec5..362bb8508459 100644
--- a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
+++ b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php
@@ -80,8 +80,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create two fields with the same name.');
     }
-    catch (EntityStorageException $e) {
-      $this->pass('Cannot create two fields with the same name.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(EntityStorageException::class, $e);
     }
 
     // Check that field type is required.
@@ -93,8 +93,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create a field with no type.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot create a field with no type.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
 
     // Check that field name is required.
@@ -106,8 +106,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create an unnamed field.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot create an unnamed field.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
     // Check that entity type is required.
     try {
@@ -118,8 +118,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create a field without an entity type.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot create a field without an entity type.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
 
     // Check that field name must start with a letter or _.
@@ -132,8 +132,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create a field with a name starting with a digit.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot create a field with a name starting with a digit.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
 
     // Check that field name must only contain lowercase alphanumeric or _.
@@ -146,8 +146,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create a field with a name containing an illegal character.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot create a field with a name containing an illegal character.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
 
     // Check that field name cannot be longer than 32 characters long.
@@ -160,8 +160,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create a field with a name longer than 32 characters.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot create a field with a name longer than 32 characters.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
 
     // Check that field name can not be an entity key.
@@ -175,8 +175,8 @@ public function testCreate() {
       FieldStorageConfig::create($field_storage_definition)->save();
       $this->fail('Cannot create a field bearing the name of an entity key.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot create a field bearing the name of an entity key.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
   }
 
@@ -380,8 +380,8 @@ public function testUpdateFieldType() {
       $field_storage->save();
       $this->fail('Cannot update a field to a different type.');
     }
-    catch (FieldException $e) {
-      $this->pass('Cannot update a field to a different type.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldException::class, $e);
     }
   }
 
@@ -480,7 +480,6 @@ public function testUpdateForbid() {
     $field_storage->setSetting('changeable', $field_storage->getSetting('changeable') + 1);
     try {
       $field_storage->save();
-      $this->pass('A changeable setting can be updated.');
     }
     catch (FieldStorageDefinitionUpdateForbiddenException $e) {
       $this->fail('An unchangeable setting cannot be updated.');
@@ -490,8 +489,8 @@ public function testUpdateForbid() {
       $field_storage->save();
       $this->fail('An unchangeable setting can be updated.');
     }
-    catch (FieldStorageDefinitionUpdateForbiddenException $e) {
-      $this->pass('An unchangeable setting cannot be updated.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(FieldStorageDefinitionUpdateForbiddenException::class, $e);
     }
   }
 
diff --git a/core/modules/filter/tests/src/Functional/FilterFormTest.php b/core/modules/filter/tests/src/Functional/FilterFormTest.php
index be90439bba00..131c4fdcfc8b 100644
--- a/core/modules/filter/tests/src/Functional/FilterFormTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterFormTest.php
@@ -207,10 +207,6 @@ protected function assertOptions($id, array $expected_options, $selected) {
     foreach ($found_options as $found_key => $found_option) {
       $expected_key = array_search($found_option->getValue(), $expected_options);
       if ($expected_key !== FALSE) {
-        $this->pass(new FormattableMarkup('Option @option for field @id exists.', [
-          '@option' => $expected_options[$expected_key],
-          '@id' => $id,
-        ]));
         unset($found_options[$found_key]);
         unset($expected_options[$expected_key]);
       }
diff --git a/core/modules/hal/tests/src/Kernel/DenormalizeTest.php b/core/modules/hal/tests/src/Kernel/DenormalizeTest.php
index 320ab65a5c30..2e89767df4a0 100644
--- a/core/modules/hal/tests/src/Kernel/DenormalizeTest.php
+++ b/core/modules/hal/tests/src/Kernel/DenormalizeTest.php
@@ -58,7 +58,7 @@ public function testTypeHandling() {
       $this->fail('Exception should be thrown when type is invalid.');
     }
     catch (UnexpectedValueException $e) {
-      $this->pass('Exception thrown when type is invalid.');
+      // Expected exception; just continue testing.
     }
 
     // No type.
@@ -70,7 +70,7 @@ public function testTypeHandling() {
       $this->fail('Exception should be thrown when no type is provided.');
     }
     catch (UnexpectedValueException $e) {
-      $this->pass('Exception thrown when no type is provided.');
+      // Expected exception; just continue testing.
     }
   }
 
diff --git a/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php b/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php
index 72fe1eb2090d..b323569cd984 100644
--- a/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php
+++ b/core/modules/image/tests/src/Kernel/Migrate/d6/MigrateImageCacheTest.php
@@ -35,15 +35,10 @@ public function testMissingTable() {
       ->condition('type', 'module')
       ->execute();
 
-    try {
-      $this->getMigration('d6_imagecache_presets')
-        ->getSourcePlugin()
-        ->checkRequirements();
-      $this->fail('Did not catch expected RequirementsException.');
-    }
-    catch (RequirementsException $e) {
-      $this->pass('Caught expected RequirementsException: ' . $e->getMessage());
-    }
+    $this->expectException(RequirementsException::class);
+    $this->getMigration('d6_imagecache_presets')
+      ->getSourcePlugin()
+      ->checkRequirements();
   }
 
   /**
@@ -162,7 +157,7 @@ protected function assertImageEffect($collection, $id, $config) {
 
       if ($effect_config['id'] == $id && $effect_config['data'] == $config) {
         // We found this effect so succeed and return.
-        return $this->pass('Effect ' . $id . ' imported correctly');
+        return TRUE;
       }
     }
     // The loop did not find the effect so we it was not imported correctly.
diff --git a/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php b/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php
index 9fe5e1cb7e02..66604e8831ad 100644
--- a/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php
+++ b/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php
@@ -48,7 +48,7 @@ public function testDependencyInjectedNewDefaultLanguage() {
       $this->fail('Expected DeleteDefaultLanguageException thrown.');
     }
     catch (DeleteDefaultLanguageException $e) {
-      $this->pass('Expected DeleteDefaultLanguageException thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Re-save the previous default language and the delete should work.
diff --git a/core/modules/media/tests/src/Kernel/EditorMediaDialogTest.php b/core/modules/media/tests/src/Kernel/EditorMediaDialogTest.php
index 7353067d548a..51f4abe18f91 100644
--- a/core/modules/media/tests/src/Kernel/EditorMediaDialogTest.php
+++ b/core/modules/media/tests/src/Kernel/EditorMediaDialogTest.php
@@ -84,9 +84,9 @@ public function testBuildForm() {
     ]);
     $form_state->setRequestMethod('POST');
 
-    EditorMediaDialog::create($this->container)
+    $form = EditorMediaDialog::create($this->container)
       ->buildForm([], $form_state, $editor->reveal());
-    $this->pass('Form was built without errors.');
+    $this->assertNotNull($form, 'Form should have been built without errors.');
   }
 
 }
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php b/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php
index c63a17154860..8974b9ef9fac 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php
@@ -64,7 +64,6 @@ public function testMenuBlock() {
     $this->verifyPageCache($url, 'HIT', $expected_tags);
 
     // Verify that after modifying the menu, there is a cache miss.
-    $this->pass('Test modification of menu.', 'Debug');
     $menu->set('label', 'Awesome llama');
     $menu->save();
     $this->verifyPageCache($url, 'MISS');
@@ -74,14 +73,12 @@ public function testMenuBlock() {
 
     // Verify that after modifying the menu link weight, there is a cache miss.
     $menu_link_manager->updateDefinition('test_page_test.test_page', ['weight' => -10]);
-    $this->pass('Test modification of menu link.', 'Debug');
     $this->verifyPageCache($url, 'MISS');
 
     // Verify a cache hit.
     $this->verifyPageCache($url, 'HIT');
 
     // Verify that after adding a menu link, there is a cache miss.
-    $this->pass('Test addition of menu link.', 'Debug');
     $menu_link_2 = MenuLinkContent::create([
       'id' => '',
       'parent' => '',
@@ -99,7 +96,6 @@ public function testMenuBlock() {
     $this->verifyPageCache($url, 'HIT');
 
     // Verify that after resetting the first menu link, there is a cache miss.
-    $this->pass('Test reset of menu link.', 'Debug');
     $this->assertTrue($menu_link->isResettable(), 'First link can be reset');
     $menu_link = $menu_link_manager->resetLink($menu_link->getPluginId());
     $this->verifyPageCache($url, 'MISS');
@@ -108,7 +104,6 @@ public function testMenuBlock() {
     $this->verifyPageCache($url, 'HIT', $expected_tags);
 
     // Verify that after deleting the menu, there is a cache miss.
-    $this->pass('Test deletion of menu.', 'Debug');
     $menu->delete();
     $this->verifyPageCache($url, 'MISS');
 
diff --git a/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php b/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
index baa9dff6b9ef..1ffae4d7e9e3 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessGrantsCacheContextTest.php
@@ -82,7 +82,6 @@ protected function assertUserCacheContext(array $expected) {
       if ($uid > 0) {
         $this->drupalLogin($this->userMapping[$uid]);
       }
-      $this->pass('Asserting cache context for user ' . $uid . '.');
       $this->assertIdentical($context, $this->container->get('cache_context.user.node_grants')->getContext('view'));
     }
     $this->drupalLogout();
diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php
index 66c29570d747..33c87ede1e01 100644
--- a/core/modules/node/tests/src/Functional/NodeCreationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php
@@ -115,7 +115,7 @@ public function testFailedPageCreation() {
       $this->fail('Expected exception has not been thrown.');
     }
     catch (\Exception $e) {
-      $this->pass('Expected exception has been thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Check that the node does not exist in the database.
diff --git a/core/modules/node/tests/src/Functional/Views/BulkFormTest.php b/core/modules/node/tests/src/Functional/Views/BulkFormTest.php
index afc07a01cf51..bf77529e53c5 100644
--- a/core/modules/node/tests/src/Functional/Views/BulkFormTest.php
+++ b/core/modules/node/tests/src/Functional/Views/BulkFormTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\node\Functional\Views;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\views\Views;
 
@@ -60,7 +59,6 @@ protected function setUp($import_test_views = TRUE): void {
         'promote' => FALSE,
       ];
       $node = $this->drupalCreateNode($values);
-      $this->pass(new FormattableMarkup('Node %title created with language %langcode.', ['%title' => $node->label(), '%langcode' => $node->language()->getId()]));
       $this->nodes[] = $node;
     }
 
@@ -71,7 +69,6 @@ protected function setUp($import_test_views = TRUE): void {
         if (!$node->hasTranslation($langcode)) {
           $title = $this->randomMachineName() . ' [' . $node->id() . ':' . $langcode . ']';
           $translation = $node->addTranslation($langcode, ['title' => $title, 'promote' => FALSE]);
-          $this->pass(new FormattableMarkup('Translation %title created with language %langcode.', ['%title' => $translation->label(), '%langcode' => $translation->language()->getId()]));
         }
       }
       $node->save();
@@ -82,7 +79,6 @@ protected function setUp($import_test_views = TRUE): void {
     $langcode = 'en';
     $title = $this->randomMachineName() . ' [' . $node->id() . ':' . $langcode . ']';
     $translation = $node->addTranslation($langcode, ['title' => $title]);
-    $this->pass(new FormattableMarkup('Translation %title created with language %langcode.', ['%title' => $translation->label(), '%langcode' => $translation->language()->getId()]));
     $node->save();
 
     // Check that all created translations are selected by the test view.
diff --git a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php
index 0ec10e3c62a5..35e04d0905bd 100644
--- a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php
+++ b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php
@@ -304,7 +304,6 @@ protected function doTestFrontPageViewCacheTags($do_assert_views_caches) {
       'timezone',
     ]);
 
-    $this->pass('First page');
     // First page.
     $first_page_result_cache_tags = [
       'config:views.view.frontpage',
@@ -344,7 +343,6 @@ protected function doTestFrontPageViewCacheTags($do_assert_views_caches) {
     );
 
     // Second page.
-    $this->pass('Second page');
     $this->assertPageCacheContextsAndTags(Url::fromRoute('view.frontpage.page_1', [], ['query' => ['page' => 1]]), $cache_contexts, [
       // The cache tags for the listed nodes.
       'node:1',
diff --git a/core/modules/options/tests/src/Kernel/OptionsFieldTest.php b/core/modules/options/tests/src/Kernel/OptionsFieldTest.php
index 55d8732479ca..0ba5d44bf220 100644
--- a/core/modules/options/tests/src/Kernel/OptionsFieldTest.php
+++ b/core/modules/options/tests/src/Kernel/OptionsFieldTest.php
@@ -43,7 +43,7 @@ public function testUpdateAllowedValues() {
       $this->fail('Cannot update a list field storage to not include keys with existing data.');
     }
     catch (FieldStorageDefinitionUpdateForbiddenException $e) {
-      $this->pass('Cannot update a list field storage to not include keys with existing data.');
+      // Expected exception; just continue testing.
     }
     // Empty the value, so that we can actually remove the option.
     unset($entity->{$this->fieldName});
diff --git a/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php b/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
index 6b3e8a670f7e..f16c6e77e632 100644
--- a/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
+++ b/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php
@@ -61,7 +61,7 @@ public function testGetRdfNamespaces() {
       $this->fail('Expected exception not thrown for conflicting namespace declaration.');
     }
     catch (\Exception $e) {
-      $this->pass('Expected exception thrown: ' . $e->getMessage());
+      // Expected exception; just continue testing.
     }
   }
 
diff --git a/core/modules/serialization/tests/src/Kernel/SerializationTest.php b/core/modules/serialization/tests/src/Kernel/SerializationTest.php
index b4ac02e0812f..91d832a4b378 100644
--- a/core/modules/serialization/tests/src/Kernel/SerializationTest.php
+++ b/core/modules/serialization/tests/src/Kernel/SerializationTest.php
@@ -48,7 +48,7 @@ public function testSerializerComponentRegistration() {
       $this->fail('The serializer was expected to throw an exception for an unsupported format, but did not.');
     }
     catch (UnexpectedValueException $e) {
-      $this->pass('The serializer threw an exception for an unsupported format.');
+      // Expected exception; just continue testing.
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/Common/UrlTest.php b/core/modules/system/tests/src/Functional/Common/UrlTest.php
index c7ef3fdef7cb..20686be4bd25 100644
--- a/core/modules/system/tests/src/Functional/Common/UrlTest.php
+++ b/core/modules/system/tests/src/Functional/Common/UrlTest.php
@@ -71,7 +71,6 @@ public function testLinkBubbleableMetadata() {
         '#url' => Url::fromUri($uri),
       ];
       \Drupal::service('renderer')->renderRoot($link);
-      $this->pass($title);
       $this->assertEqual($expected_cacheability, $link['#cache']);
       $this->assertEqual($expected_attachments, $link['#attached']);
     }
diff --git a/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php b/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php
index bccc4f532219..a310c632e73c 100644
--- a/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php
+++ b/core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php
@@ -57,15 +57,12 @@ protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL
     $tested_tags = implode(', ', array_unique($matches[1]));
     $message .= ' (' . $tested_tags . ')';
     $result = MailFormatHelper::htmlToText($html, $allowed_tags);
-    $pass = $this->assertEqual($result, $text, Html::escape($message));
+    $this->assertEqual($result, $text, Html::escape($message));
     $verbose = 'html = <pre>' . $this->stringToHtml($html)
       . '</pre><br />result = <pre>' . $this->stringToHtml($result)
       . '</pre><br />expected = <pre>' . $this->stringToHtml($text)
       . '</pre>';
     $this->verbose($verbose);
-    if (!$pass) {
-      $this->pass("Previous test verbose info:<br />$verbose");
-    }
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php
index 5b0faa7e1c70..509fa990a219 100644
--- a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php
+++ b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\system\Functional\Menu;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Utility\Html;
 use Drupal\Core\Url;
 use Drupal\Tests\BrowserTestBase;
@@ -61,12 +60,7 @@ protected function assertLocalTasks(array $routes, $level = 0) {
     foreach ($routes as $index => $route_info) {
       list($route_name, $route_parameters) = $route_info;
       $expected = Url::fromRoute($route_name, $route_parameters)->toString();
-      $method = ($elements[$index]->getAttribute('href') == $expected ? 'pass' : 'fail');
-      $this->{$method}(new FormattableMarkup('Task @number href @value equals @expected.', [
-        '@number' => $index + 1,
-        '@value' => $elements[$index]->getAttribute('href'),
-        '@expected' => $expected,
-      ]));
+      $this->assertEquals($expected, $elements[$index]->getAttribute('href'), "Task " . ($index + 1) . "number href " . $elements[$index]->getAttribute('href') . " equals $expected.");
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/Module/InstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallTest.php
index e6a83e932388..772651ba34d6 100644
--- a/core/modules/system/tests/src/Functional/Module/InstallTest.php
+++ b/core/modules/system/tests/src/Functional/Module/InstallTest.php
@@ -82,8 +82,8 @@ public function testModuleNameLength() {
       $this->container->get('module_installer')->install([$module_name]);
       $this->fail($message);
     }
-    catch (ExtensionNameLengthException $e) {
-      $this->pass($message);
+    catch (\Exception $e) {
+      $this->assertInstanceOf(ExtensionNameLengthException::class, $e);
     }
 
     // Since for the UI, the submit callback uses FALSE, test that too.
@@ -92,8 +92,8 @@ public function testModuleNameLength() {
       $this->container->get('module_installer')->install([$module_name], FALSE);
       $this->fail($message);
     }
-    catch (ExtensionNameLengthException $e) {
-      $this->pass($message);
+    catch (\Exception $e) {
+      $this->assertInstanceOf(ExtensionNameLengthException::class, $e);
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php
index 3c5e9fb3596c..1d3566be1b99 100644
--- a/core/modules/system/tests/src/Functional/Module/UninstallTest.php
+++ b/core/modules/system/tests/src/Functional/Module/UninstallTest.php
@@ -157,7 +157,7 @@ public function testFailedInstallStatus() {
       $this->fail($message);
     }
     catch (EntityMalformedException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Even though the module failed to install properly, its configuration
diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
index b97ab7787f15..8feb0fc4bd27 100644
--- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php
+++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
@@ -307,7 +307,7 @@ public function testRouterUninstallInstall() {
       $this->fail('Route was delete on uninstall.');
     }
     catch (RouteNotFoundException $e) {
-      $this->pass('Route was delete on uninstall.');
+      // Expected exception; just continue testing.
     }
     // Install the module again.
     \Drupal::service('module_installer')->install(['router_test']);
diff --git a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
index 4a5894794fb7..38da8000fec7 100644
--- a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
+++ b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
@@ -161,7 +161,6 @@ public function testNonHtmlRequest() {
     \Drupal::state()->set('system.maintenance_mode', TRUE);
     $formats = ['json', 'xml', 'non-existing'];
     foreach ($formats as $format) {
-      $this->pass('Testing format ' . $format);
       $this->drupalGet('<front>', ['query' => ['_format' => $format]]);
       $this->assertSession()->statusCodeEquals(503);
       $this->assertRaw('Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.');
diff --git a/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php b/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php
index fa1694734422..c96f44d2fec4 100644
--- a/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php
+++ b/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php
@@ -59,7 +59,6 @@ public function assertPageRenderHookExceptions($module, $hook) {
       $this->error($assertion);
     }
     catch (\LogicException $e) {
-      $this->pass($assertion);
       $this->assertEqual($e->getMessage(), 'Only #attached and #cache may be set in ' . $hook . '().');
     }
     \Drupal::state()->set('bc_test.' . $hook . '.descendant_attached', FALSE);
@@ -73,7 +72,6 @@ public function assertPageRenderHookExceptions($module, $hook) {
       $this->error($assertion);
     }
     catch (\LogicException $e) {
-      $this->pass($assertion);
       $this->assertEqual($e->getMessage(), 'Only #attached and #cache may be set in ' . $hook . '().');
     }
     \Drupal::state()->set($module . '.' . $hook . '.render_array', FALSE);
diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
index c1e2618795a6..241de1bba055 100644
--- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
+++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
@@ -96,7 +96,7 @@ public function testDependencyResolution() {
       $this->fail('ModuleInstaller::install() throws an exception if dependencies are missing.');
     }
     catch (MissingDependencyException $e) {
-      $this->pass('ModuleInstaller::install() throws an exception if dependencies are missing.');
+      // Expected exception; just continue testing.
     }
 
     $this->assertFalse($this->moduleHandler()->moduleExists('color'), 'ModuleInstaller::install() aborts if dependencies are missing.');
@@ -254,7 +254,7 @@ public function testUninstallContentDependency() {
       $this->fail($message);
     }
     catch (ModuleUninstallValidatorException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     // Uninstalling help needs entity_test to be un-installable.
@@ -264,7 +264,7 @@ public function testUninstallContentDependency() {
       $this->fail($message);
     }
     catch (ModuleUninstallValidatorException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     // Deleting the entity.
diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php
index 37f2e3d309c9..6f4987182852 100644
--- a/core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php
+++ b/core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php
@@ -131,12 +131,7 @@ protected function assertToolbarCacheContexts(array $cache_contexts, $message =
     $this->drupalGet('test-page');
     $return = $return && $this->assertCacheContexts($cache_contexts);
 
-    if ($return) {
-      $this->pass($message);
-    }
-    else {
-      $this->fail($message);
-    }
+    $this->assertTrue($return, $message);
     return $return;
   }
 
diff --git a/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php b/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php
index a9175c290cf4..d5a587f2c681 100644
--- a/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php
+++ b/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php
@@ -59,7 +59,6 @@ public function testRenderedTour() {
     $this->verifyPageCache($url, 'HIT', $expected_tags);
 
     // Verify that after modifying the tour, there is a cache miss.
-    $this->pass('Test modification of tour.', 'Debug');
     Tour::load('tour-test')->save();
     $this->verifyPageCache($url, 'MISS');
 
@@ -67,7 +66,6 @@ public function testRenderedTour() {
     $this->verifyPageCache($url, 'HIT', $expected_tags);
 
     // Verify that after deleting the tour, there is a cache miss.
-    $this->pass('Test deletion of tour.', 'Debug');
     Tour::load('tour-test')->delete();
     $this->verifyPageCache($url, 'MISS');
 
diff --git a/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php b/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php
index b4b9c82218c1..838649599333 100644
--- a/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php
+++ b/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php
@@ -89,11 +89,9 @@ public function testFieldBasedViewCacheTagsWithCachePluginTime() {
    *   Whether to check Views' result & output caches.
    */
   protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
-    $this->pass('Checking cache tags for field-based view.');
     $view = Views::getview('entity_test_fields');
 
     // Empty result (no entities yet).
-    $this->pass('Test without entities');
     $base_tags = ['config:views.view.entity_test_fields', 'entity_test_list'];
     $this->assertViewsCacheTags($view, $base_tags, $do_assert_views_caches, $base_tags);
     $this->assertViewsCacheTagsFromStaticRenderArray($view, $base_tags, $do_assert_views_caches);
@@ -103,7 +101,6 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
     $entities[] = $entity = EntityTest::create();
     $entity->save();
 
-    $this->pass('Test with entities');
     $tags_with_entity = Cache::mergeTags($base_tags, $entities[0]->getCacheTags());
     $this->assertViewsCacheTags($view, $tags_with_entity, $do_assert_views_caches, $tags_with_entity);
     $this->assertViewsCacheTagsFromStaticRenderArray($view, $tags_with_entity, $do_assert_views_caches);
@@ -114,9 +111,8 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
       $entity->save();
     }
 
+    // Test pager.
     // Page 1.
-    $this->pass('Test pager');
-    $this->pass('Page 1');
     \Drupal::request()->query->set('page', 0);
     $tags_page_1 = Cache::mergeTags($base_tags, $entities[1]->getCacheTags());
     $tags_page_1 = Cache::mergeTags($tags_page_1, $entities[2]->getCacheTags());
@@ -127,7 +123,6 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
     $this->assertViewsCacheTagsFromStaticRenderArray($view, $tags_page_1, $do_assert_views_caches);
     $view->destroy();
     // Page 2.
-    $this->pass('Page 2');
     $view->setCurrentPage(1);
     \Drupal::request()->query->set('page', 1);
     $tags_page_2 = Cache::mergeTags($base_tags, $entities[0]->getCacheTags());
@@ -135,8 +130,7 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
     $view->destroy();
 
     // Ensure that invalidation works on both pages.
-    $this->pass('Page invalidations');
-    $this->pass('Page 2');
+    // Page 2.
     $view->setCurrentPage(1);
     \Drupal::request()->query->set('page', 1);
     $entities[0]->name->value = $random_name = $this->randomMachineName();
@@ -148,7 +142,7 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
     $this->assertStringContainsString($random_name, (string) $build['#markup']);
     $view->destroy();
 
-    $this->pass('Page 1');
+    // Page 1.
     $view->setCurrentPage(0);
     \Drupal::request()->query->set('page', 0);
     $entities[1]->name->value = $random_name = $this->randomMachineName();
@@ -159,8 +153,6 @@ protected function assertCacheTagsForFieldBasedView($do_assert_views_caches) {
     $view->destroy();
 
     // Setup arguments to ensure that render caching also varies by them.
-    $this->pass('Test arguments');
-
     // Custom assert for a single result row.
     $single_entity_assertions = function (array $build, EntityInterface $entity) {
       $this->setRawContent($build['#markup']);
@@ -239,7 +231,6 @@ public function testEntityBasedViewCacheTagsWithCachePluginTime() {
    * Tests cache tags on output & result cache items for an entity-based view.
    */
   protected function assertCacheTagsForEntityBasedView($do_assert_views_caches) {
-    $this->pass('Checking cache tags for entity-based view.');
     $view = Views::getview('entity_test_row');
 
     // Empty result (no entities yet).
diff --git a/core/modules/views/tests/src/Kernel/ViewsConfigUpdaterTest.php b/core/modules/views/tests/src/Kernel/ViewsConfigUpdaterTest.php
index 9a94a0de2530..1b9bb0bb3bc8 100644
--- a/core/modules/views/tests/src/Kernel/ViewsConfigUpdaterTest.php
+++ b/core/modules/views/tests/src/Kernel/ViewsConfigUpdaterTest.php
@@ -138,11 +138,10 @@ public function testUpdateAll() {
 
     foreach ($view_ids as $view_id) {
       $test_view = $this->loadTestView($view_id);
-      $this->configUpdater->updateAll($test_view);
+      $this->assertTrue($this->configUpdater->updateAll($test_view), "View $view_id should be updated.");
     }
 
     // @todo Improve this in https://www.drupal.org/node/3121008.
-    $this->pass('Views processed');
   }
 
 }
diff --git a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
index 12d913312425..df76829fadd7 100644
--- a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
+++ b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
@@ -83,7 +83,6 @@ protected function assertDefaultConfig(StorageInterface $default_config_storage,
           // FunctionalTestSetupTrait::installParameters().
           'system.site' => ['uuid:', 'name:', 'mail:'],
         ]);
-        $this->pass("$config_name has no differences");
       }
       else {
         $this->fail("$config_name has not been installed");
diff --git a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php
index a5f5fb9e171a..6fa15c4e5515 100644
--- a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php
+++ b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php
@@ -240,8 +240,7 @@ public function testLostDatabaseConnection() {
 
       default:
         // We can not carry out this test.
-        $this->pass('Unable to run \Drupal\system\Tests\System\UncaughtExceptionTest::testLostDatabaseConnection for this database type.');
-        return;
+        $this->markTestSkipped('Unable to run \Drupal\system\Tests\System\UncaughtExceptionTest::testLostDatabaseConnection for this database type.');
     }
 
     // We simulate a broken database connection by rewrite settings.php to no
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index c1b6fcb8c0f5..f91bdfaecc96 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -328,7 +328,7 @@ public function testXpathAsserts() {
       $this->fail('The "notexisting" field was found.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass('assertFieldByXPath correctly failed. The "notexisting" field was not found.');
+      // Expected exception; just continue testing.
     }
 
     try {
@@ -336,7 +336,7 @@ public function testXpathAsserts() {
       $this->fail('The "edit-name" field was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoFieldByXPath correctly failed. The "edit-name" field was found.');
+      // Expected exception; just continue testing.
     }
 
     try {
@@ -344,7 +344,7 @@ public function testXpathAsserts() {
       $this->fail('The "edit-name" field is found with the value "not the value".');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass('The "edit-name" field is not found with the value "not the value".');
+      // Expected exception; just continue testing.
     }
   }
 
@@ -363,7 +363,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "name" field was not found based on name.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoField correctly failed. The "name" field was found by name.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the assertion fails correctly when searching by id.
@@ -372,7 +372,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "name" field was not found based on id.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoField correctly failed. The "name" field was found by id.');
+      // Expected exception; just continue testing.
     }
 
     // *** 2. assertField().
@@ -385,7 +385,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "invalid_name_and_id" field was found.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass('assertField correctly failed. The "invalid_name_and_id" field was not found.');
+      // Expected exception; just continue testing.
     }
 
     // *** 3. assertNoFieldById().
@@ -400,7 +400,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "description" field, with no value was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass('The "description" field, with no value was found.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the assertion fails correctly if a NULL value is passed in.
@@ -409,7 +409,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "name" field was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass('The "name" field was found.');
+      // Expected exception; just continue testing.
     }
 
     // *** 4. assertFieldById().
@@ -424,7 +424,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "edit-name" field with no value was found.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass('The "edit-name" field with no value was not found.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the assertion fails correctly if the wrong value is passed in.
@@ -433,7 +433,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "name" field was found, using the wrong value.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass('The "name" field was not found, using the wrong value.');
+      // Expected exception; just continue testing.
     }
 
     // *** 5. assertNoFieldByName().
@@ -448,7 +448,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "description" field, with no value was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass('The "description" field, with no value was found.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the assertion fails correctly if a NULL value is passed in.
@@ -457,7 +457,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "name" field was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass('The "name" field was found.');
+      // Expected exception; just continue testing.
     }
 
     // *** 6. assertFieldByName().
@@ -474,7 +474,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "non-existing-name" field was found.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass('The "non-existing-name" field was not found');
+      // Expected exception; just continue testing.
     }
 
     // Test that the assertion fails correctly if given the wrong value.
@@ -483,7 +483,7 @@ public function testFieldAssertsForTextfields() {
       $this->fail('The "name" field with incorrect value was found.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass('assertFieldByName correctly failed. The "name" field with incorrect value was not found.');
+      // Expected exception; just continue testing.
     }
 
     // Test that text areas can contain new lines.
@@ -508,7 +508,7 @@ public function testFieldAssertsForOptions() {
       $this->fail('The select option "four" was found.');
     }
     catch (ExpectationException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     $this->assertOption('options', 1);
@@ -517,7 +517,7 @@ public function testFieldAssertsForOptions() {
       $this->fail('The select option "4" was found.');
     }
     catch (ExpectationException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     $this->assertNoOption('options', 'non-existing');
@@ -526,7 +526,7 @@ public function testFieldAssertsForOptions() {
       $this->fail('The select option "one" was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     $this->assertTrue($this->assertSession()->optionExists('options', 2)->isSelected());
@@ -535,7 +535,7 @@ public function testFieldAssertsForOptions() {
       $this->fail('The select option "4" was selected.');
     }
     catch (ExpectationException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     try {
@@ -543,7 +543,7 @@ public function testFieldAssertsForOptions() {
       $this->fail('The select option "1" was selected.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
 
   }
@@ -562,7 +562,7 @@ public function testFieldAssertsForButton() {
       $this->fail('The field with id of "Save" was found.');
     }
     catch (ExpectationFailedException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     $this->assertNoFieldById('Save', NULL);
@@ -573,7 +573,7 @@ public function testFieldAssertsForButton() {
       $this->fail('The field with id of "edit-save" was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     // Test that multiple fields with the same name are validated correctly.
@@ -586,7 +586,7 @@ public function testFieldAssertsForButton() {
       $this->fail('The "duplicate_button" field with the value Duplicate button 2 was not found.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoFieldByName correctly failed. The "duplicate_button" field with the value Duplicate button 2 was found.');
+      // Expected exception; just continue testing.
     }
   }
 
@@ -623,7 +623,7 @@ public function testFieldAssertsForCheckbox() {
       $this->fail('The "checkbox_enabled" field was not found by name, using NULL value.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoFieldByName failed correctly. The "checkbox_enabled" field was found using NULL value.');
+      // Expected exception; just continue testing.
     }
 
     // Part 2 - Test by ID.
@@ -653,7 +653,7 @@ public function testFieldAssertsForCheckbox() {
       $this->fail('The "edit-checkbox-disabled" field was not found by ID, using NULL value.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoFieldById failed correctly. The "edit-checkbox-disabled" field was found by ID using NULL value.');
+      // Expected exception; just continue testing.
     }
 
     // Part 3 - Test the specific 'checked' assertions.
@@ -666,7 +666,7 @@ public function testFieldAssertsForCheckbox() {
       $this->fail('The "incorrect_checkbox_id" field was found');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoFieldChecked correctly failed. The "incorrect_checkbox_id" field was not found.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the assertion fails correctly for a checkbox that is checked.
@@ -675,7 +675,7 @@ public function testFieldAssertsForCheckbox() {
       $this->fail('The "edit-checkbox-enabled" field was not found in a checked state.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertNoFieldChecked correctly failed. The "edit-checkbox-enabled" field was found in a checked state.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the assertion fails correctly for a checkbox that is not
@@ -685,7 +685,7 @@ public function testFieldAssertsForCheckbox() {
       $this->fail('The "edit-checkbox-disabled" field was found and checked.');
     }
     catch (ExpectationException $e) {
-      $this->pass('assertFieldChecked correctly failed. The "edit-checkbox-disabled" field was not found in a checked state.');
+      // Expected exception; just continue testing.
     }
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php
index 1461101f051d..f833a52a250b 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php
@@ -124,7 +124,6 @@ public function testInstalled() {
     $this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.');
 
     $this->rebuildContainer();
-    $this->pass('Container can be rebuilt even though distribution is not written to settings.php.');
     $this->assertEqual(\Drupal::installProfile(), 'mydistro');
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
index 33bf61f17f63..05142ba3185e 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
@@ -85,7 +85,6 @@ public function testInstalled() {
     $this->assertEqual($this->config('core.extension')->get('profile'), 'distribution_one', 'The install profile has been written to core.extension configuration.');
 
     $this->rebuildContainer();
-    $this->pass('Container can be rebuilt as distribution is written to configuration.');
     $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
   }
 
diff --git a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
index f0da2a736b02..b8b4c618977f 100644
--- a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
+++ b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
@@ -118,10 +118,9 @@ protected function doTestsOnConfigStorage(StorageInterface $default_config_stora
           $entity_storage->load($id)->calculateDependencies()->save();
         }
         $result = $config_manager->diff($default_config_storage, $active_config_storage, $config_name);
-        $this->assertConfigDiff($result, $config_name, static::$skippedConfig);
-        // The method call above will throw an exception if the configuration is
+        // ::assertConfigDiff will throw an exception if the configuration is
         // different.
-        $this->pass("$config_name has no differences");
+        $this->assertNull($this->assertConfigDiff($result, $config_name, static::$skippedConfig));
       }
       else {
         $info = $this->container->get('extension.list.module')->getExtensionInfo($module);
diff --git a/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
index fc0597322226..19c61996de93 100644
--- a/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
@@ -229,8 +229,7 @@ protected function activateTheme($theme_name) {
 
     $this->libraryDiscovery->clearCachedDefinitions();
 
-    // Assert message.
-    $this->pass(sprintf('Activated theme "%s"', $theme_name));
+    $this->assertSame($theme_name, $theme_manager->getActiveTheme()->getName());
   }
 
   /**
@@ -257,7 +256,7 @@ protected function assertAssetInLibrary($asset, $extension, $library_name, $sub_
     $library = $this->libraryDiscovery->getLibraryByName($extension, $library_name);
     foreach ($library[$sub_key] as $definition) {
       if ($asset == $definition['data']) {
-        return $this->pass($message);
+        return TRUE;
       }
     }
     return $this->fail($message);
@@ -290,7 +289,7 @@ protected function assertNoAssetInLibrary($asset, $extension, $library_name, $su
         return $this->fail($message);
       }
     }
-    return $this->pass($message);
+    return TRUE;
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php b/core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php
index 99fa58b88d0c..2192d0ec73ca 100644
--- a/core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php
@@ -44,15 +44,6 @@ class DbDumpTest extends KernelTestBase {
    */
   protected $data;
 
-  /**
-   * Flag to skip these tests, which are database-backend dependent (MySQL).
-   *
-   * @see \Drupal\Core\Command\DbDumpCommand
-   *
-   * @var bool
-   */
-  protected $skipTests = FALSE;
-
   /**
    * An array of original table schemas.
    *
@@ -93,8 +84,9 @@ public function register(ContainerBuilder $container) {
   protected function setUp(): void {
     parent::setUp();
 
-    // Determine what database backend is running, and set the skip flag.
-    $this->skipTests = Database::getConnection()->databaseType() !== 'mysql';
+    if (Database::getConnection()->databaseType() !== 'mysql') {
+      $this->markTestSkipped("Skipping test since the DbDumpCommand is currently only compatible with MySql");
+    }
 
     // Create some schemas so our export contains tables.
     $this->installSchema('system', [
@@ -162,11 +154,6 @@ protected function setUp(): void {
    * Test the command directly.
    */
   public function testDbDumpCommand() {
-    if ($this->skipTests) {
-      $this->pass("Skipping test since the DbDumpCommand is currently only compatible with MySql");
-      return;
-    }
-
     $application = new DbDumpApplication();
     $command = $application->find('dump-database-d8-mysql');
     $command_tester = new CommandTester($command);
@@ -196,11 +183,6 @@ public function testDbDumpCommand() {
    * Test loading the script back into the database.
    */
   public function testScriptLoad() {
-    if ($this->skipTests) {
-      $this->pass("Skipping test since the DbDumpCommand is currently only compatible with MySql");
-      return;
-    }
-
     // Generate the script.
     $application = new DbDumpApplication();
     $command = $application->find('dump-database-d8-mysql');
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php
index be0d2db284d5..e76ce3e8963b 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php
@@ -193,24 +193,22 @@ public function testCRUD() {
   public function testNameValidation() {
     // Verify that an object name without namespace causes an exception.
     $name = 'nonamespace';
-    $message = 'Expected ConfigNameException was thrown for a name without a namespace.';
     try {
       $this->config($name)->save();
-      $this->fail($message);
+      $this->fail('Expected ConfigNameException was thrown for a name without a namespace.');
     }
-    catch (ConfigNameException $e) {
-      $this->pass($message);
+    catch (\Exception $e) {
+      $this->assertInstanceOf(ConfigNameException::class, $e);
     }
 
     // Verify that a name longer than the maximum length causes an exception.
     $name = 'config_test.herman_melville.moby_dick_or_the_whale.harper_1851.now_small_fowls_flew_screaming_over_the_yet_yawning_gulf_a_sullen_white_surf_beat_against_its_steep_sides_then_all_collapsed_and_the_great_shroud_of_the_sea_rolled_on_as_it_rolled_five_thousand_years_ago';
-    $message = 'Expected ConfigNameException was thrown for a name longer than Config::MAX_NAME_LENGTH.';
     try {
       $this->config($name)->save();
-      $this->fail($message);
+      $this->fail('Expected ConfigNameException was thrown for a name longer than Config::MAX_NAME_LENGTH.');
     }
-    catch (ConfigNameException $e) {
-      $this->pass($message);
+    catch (\Exception $e) {
+      $this->assertInstanceOf(ConfigNameException::class, $e);
     }
 
     // Verify that disallowed characters in the name cause an exception.
@@ -231,14 +229,12 @@ public function testNameValidation() {
 
     // Verify that a valid config object name can be saved.
     $name = 'namespace.object';
-    $message = 'ConfigNameException was not thrown for a valid object name.';
     try {
       $config = $this->config($name);
       $config->save();
-      $this->pass($message);
     }
     catch (ConfigNameException $e) {
-      $this->fail($message);
+      $this->fail('ConfigNameException was not thrown for a valid object name.');
     }
 
   }
@@ -248,23 +244,21 @@ public function testNameValidation() {
    */
   public function testValueValidation() {
     // Verify that setData() will catch dotted keys.
-    $message = 'Expected ConfigValueException was thrown from setData() for value with dotted keys.';
     try {
       $this->config('namespace.object')->setData(['key.value' => 12])->save();
-      $this->fail($message);
+      $this->fail('Expected ConfigValueException was thrown from setData() for value with dotted keys.');
     }
-    catch (ConfigValueException $e) {
-      $this->pass($message);
+    catch (\Exception $e) {
+      $this->assertInstanceOf(ConfigValueException::class, $e);
     }
 
     // Verify that set() will catch dotted keys.
-    $message = 'Expected ConfigValueException was thrown from set() for value with dotted keys.';
     try {
       $this->config('namespace.object')->set('foo', ['key.value' => 12])->save();
-      $this->fail($message);
+      $this->fail('Expected ConfigValueException was thrown from set() for value with dotted keys.');
     }
-    catch (ConfigValueException $e) {
-      $this->pass($message);
+    catch (\Exception $e) {
+      $this->assertInstanceOf(ConfigValueException::class, $e);
     }
   }
 
@@ -325,9 +319,7 @@ public function testDataTypes() {
       $this->fail('No Exception thrown upon saving invalid data type.');
     }
     catch (UnsupportedDataTypeConfigException $e) {
-      $this->pass(new FormattableMarkup('%class thrown upon saving invalid data type.', [
-        '%class' => get_class($e),
-      ]));
+      // Expected exception; just continue testing.
     }
 
     // Test that setting an unsupported type for a config object with no schema
@@ -342,9 +334,7 @@ public function testDataTypes() {
       $this->fail('No Exception thrown upon saving invalid data type.');
     }
     catch (UnsupportedDataTypeConfigException $e) {
-      $this->pass(new FormattableMarkup('%class thrown upon saving invalid data type.', [
-        '%class' => get_class($e),
-      ]));
+      // Expected exception; just continue testing.
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php
index eff4d4c4eadd..5ff7f1d34490 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\KernelTests\Core\Config;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Config\ConfigDuplicateUUIDException;
 use Drupal\KernelTests\KernelTestBase;
 
@@ -44,7 +43,7 @@ public function testUUIDConflict() {
       $this->fail('Exception thrown when attempting to save a configuration entity with a UUID that does not match the existing UUID.');
     }
     catch (ConfigDuplicateUUIDException $e) {
-      $this->pass(new FormattableMarkup('Exception thrown when attempting to save a configuration entity with a UUID that does not match existing data: %e.', ['%e' => $e]));
+      // Expected exception; just continue testing.
     }
 
     // Ensure that the config entity was not corrupted.
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php
index 0a36dd2eefbc..d5d1fc6dac10 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php
@@ -40,13 +40,8 @@ public function testExportStorage() {
     }
 
     // Test that the export storage is read-only.
-    try {
-      $export->deleteAll();
-      $this->fail("export storage must not allow editing");
-    }
-    catch (\BadMethodCallException $exception) {
-      $this->pass("Exception is thrown.");
-    }
+    $this->expectException(\BadMethodCallException::class);
+    $export->deleteAll();
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
index 8b5df2c5d4f8..68546b381a07 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
@@ -110,7 +110,6 @@ public function testRenameValidation() {
       $this->fail('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.');
     }
     catch (ConfigImporterException $e) {
-      $this->pass('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.');
       $expected = [
         new FormattableMarkup('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => 'node_type', '@new_type' => 'config_test', '@old_name' => 'node.type.' . $content_type->id(), '@new_name' => 'config_test.dynamic.' . $test_entity_id]),
       ];
@@ -153,7 +152,6 @@ public function testRenameSimpleConfigValidation() {
       $this->fail('Expected ConfigImporterException thrown when simple configuration is renamed.');
     }
     catch (ConfigImporterException $e) {
-      $this->pass('Expected ConfigImporterException thrown when simple configuration is renamed.');
       $expected = [
         new FormattableMarkup('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => 'config_test.old', '@new_name' => 'config_test.new']),
       ];
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php
index d05429864d7d..1e6c1b3ead32 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php
@@ -84,14 +84,9 @@ public function testNoImport() {
    * fails.
    */
   public function testEmptyImportFails() {
-    try {
-      $this->container->get('config.storage.sync')->deleteAll();
-      $this->configImporter->reset()->import();
-      $this->fail('ConfigImporterException thrown, successfully stopping an empty import.');
-    }
-    catch (ConfigImporterException $e) {
-      $this->pass('ConfigImporterException thrown, successfully stopping an empty import.');
-    }
+    $this->expectException(ConfigImporterException::class);
+    $this->container->get('config.storage.sync')->deleteAll();
+    $this->configImporter->reset()->import();
   }
 
   /**
@@ -809,7 +804,7 @@ public function testInvalidStep() {
       $this->fail('Expected \InvalidArgumentException thrown');
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass('Expected \InvalidArgumentException thrown');
+      // Expected exception; just continue testing.
     }
     $this->assertFalse(\Drupal::isConfigSyncing(), 'After an invalid step \Drupal::isConfigSyncing() returns FALSE');
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php
index a913fa8b5192..f66b3e4a9fd8 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php
@@ -560,35 +560,29 @@ public function testConfigSchemaInfoAlter() {
     // Ensure that keys can not be added or removed by
     // hook_config_schema_info_alter().
     \Drupal::state()->set('config_schema_test_exception_remove', TRUE);
-    $message = 'Expected ConfigSchemaAlterException thrown.';
     try {
       $typed_config->getDefinitions();
-      $this->fail($message);
+      $this->fail('Expected ConfigSchemaAlterException thrown.');
     }
     catch (ConfigSchemaAlterException $e) {
-      $this->pass($message);
       $this->assertEqual($e->getMessage(), 'Invoking hook_config_schema_info_alter() has removed (config_schema_test.hook) schema definitions');
     }
 
     \Drupal::state()->set('config_schema_test_exception_add', TRUE);
-    $message = 'Expected ConfigSchemaAlterException thrown.';
     try {
       $typed_config->getDefinitions();
-      $this->fail($message);
+      $this->fail('Expected ConfigSchemaAlterException thrown.');
     }
     catch (ConfigSchemaAlterException $e) {
-      $this->pass($message);
       $this->assertEqual($e->getMessage(), 'Invoking hook_config_schema_info_alter() has added (config_schema_test.hook_added_defintion) and removed (config_schema_test.hook) schema definitions');
     }
 
     \Drupal::state()->set('config_schema_test_exception_remove', FALSE);
-    $message = 'Expected ConfigSchemaAlterException thrown.';
     try {
       $typed_config->getDefinitions();
-      $this->fail($message);
+      $this->fail('Expected ConfigSchemaAlterException thrown.');
     }
     catch (ConfigSchemaAlterException $e) {
-      $this->pass($message);
       $this->assertEqual($e->getMessage(), 'Invoking hook_config_schema_info_alter() has added (config_schema_test.hook_added_defintion) schema definitions');
     }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php
index 05748570b192..19905df2f574 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php
@@ -82,7 +82,6 @@ public function testReadUnsupportedDataTypeConfigException() {
       $config_parsed = $this->storage->read('core.extension');
     }
     catch (UnsupportedDataTypeConfigException $e) {
-      $this->pass('Exception thrown when trying to read a field containing invalid data type.');
       $this->assertStringContainsString($this->storage->getFilePath('core.extension'), $e->getMessage(), 'Erroneous file path is displayed.');
     }
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
index b56e4cc4c1e8..1a9a929e6c0d 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
@@ -144,33 +144,17 @@ public function testMultipleStatementsForNewPhp() {
       $this->markTestSkipped("This test only runs for MySQL");
     }
 
-    $db = Database::getConnection('default', 'default');
     // Disable the protection at the PHP level.
-    try {
-      $db->query('SELECT * FROM {test}; SELECT * FROM {test_people}',
-        [],
-        ['allow_delimiter_in_query' => TRUE]
-      );
-      $this->fail('No PDO exception thrown for multiple statements.');
-    }
-    catch (DatabaseExceptionWrapper $e) {
-      $this->pass('PDO exception thrown for multiple statements.');
-    }
+    $this->expectException(DatabaseExceptionWrapper::class);
+    Database::getConnection('default', 'default')->query('SELECT * FROM {test}; SELECT * FROM {test_people}', [], ['allow_delimiter_in_query' => TRUE]);
   }
 
   /**
    * Ensure that you cannot execute multiple statements.
    */
   public function testMultipleStatements() {
-
-    $db = Database::getConnection('default', 'default');
-    try {
-      $db->query('SELECT * FROM {test}; SELECT * FROM {test_people}');
-      $this->fail('No exception thrown for multiple statements.');
-    }
-    catch (\InvalidArgumentException $e) {
-      $this->pass('Exception thrown for multiple statements.');
-    }
+    $this->expectException(\InvalidArgumentException::class);
+    Database::getConnection('default', 'default')->query('SELECT * FROM {test}; SELECT * FROM {test_people}');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php b/core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php
index b371d968a6b4..0d2ea9fdc423 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php
@@ -32,14 +32,8 @@ public function testPrepare() {
 
       $this->fail('Expected PDOException or DatabaseExceptionWrapper, none was thrown.');
     }
-    catch (\PDOException $e) {
-      $this->pass('Expected PDOException was thrown.');
-    }
-    catch (DatabaseExceptionWrapper $e) {
-      $this->pass('Expected DatabaseExceptionWrapper was thrown.');
-    }
     catch (\Exception $e) {
-      $this->fail("Thrown exception is not a PDOException:\n" . (string) $e);
+      $this->assertTrue($e instanceof \PDOException || $e instanceof DatabaseExceptionWrapper, 'Exception should be an instance of \PDOException or DatabaseExceptionWrapper, thrown ' . get_class($e));
     }
   }
 
@@ -68,17 +62,8 @@ public function testPrepareStatement() {
    * Tests the expected database exception thrown for inexistent tables.
    */
   public function testQueryThrowsDatabaseExceptionWrapperException() {
-    $connection = Database::getConnection();
-    try {
-      $connection->query('SELECT * FROM {does_not_exist}');
-      $this->fail('Expected PDOException, none was thrown.');
-    }
-    catch (DatabaseExceptionWrapper $e) {
-      $this->pass('Expected DatabaseExceptionWrapper was thrown.');
-    }
-    catch (\Exception $e) {
-      $this->fail("Thrown exception is not a DatabaseExceptionWrapper:\n" . (string) $e);
-    }
+    $this->expectException(DatabaseExceptionWrapper::class);
+    Database::getConnection()->query('SELECT * FROM {does_not_exist}');
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
index 9b54800e9b26..73cd2d331d45 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php
@@ -36,7 +36,7 @@ public function testDefaultEmptyInsert() {
       $this->fail('Expected exception NoFieldsException has not been thrown.');
     }
     catch (NoFieldsException $e) {
-      $this->pass('Expected exception NoFieldsException has been thrown.');
+      // Expected exception; just continue testing.
     }
 
     $num_records_after = (int) $this->connection->query('SELECT COUNT(*) FROM {test}')->fetchField();
diff --git a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php
index ba254e88ab63..563f59f21d12 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php
@@ -207,11 +207,9 @@ public function testInvalidMerge() {
           'name' => 'Tiffany',
         ])
         ->execute();
-      $this->pass('$options[\'throw_exception\'] is FALSE, no InvalidMergeQueryException thrown.');
     }
     catch (InvalidMergeQueryException $e) {
       $this->fail('$options[\'throw_exception\'] is FALSE, but InvalidMergeQueryException thrown for invalid query.');
-      return;
     }
 
     try {
@@ -222,12 +220,11 @@ public function testInvalidMerge() {
           'name' => 'Tiffany',
         ])
         ->execute();
+      $this->fail('InvalidMergeQueryException should be thrown.');
     }
-    catch (InvalidMergeQueryException $e) {
-      $this->pass('InvalidMergeQueryException thrown for invalid query.');
-      return;
+    catch (\Exception $e) {
+      $this->assertInstanceOf(InvalidMergeQueryException::class, $e);
     }
-    $this->fail('No InvalidMergeQueryException thrown');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
index f41eaea1b0fa..f568f9d1b492 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
@@ -28,8 +28,8 @@ public function testScalarSubstitution() {
       $names = $this->connection->query('SELECT [name] FROM {test} WHERE [age] IN ( :ages[] ) ORDER BY [age]', [':ages[]' => 25])->fetchAll();
       $this->fail('Array placeholder with scalar argument should result in an exception.');
     }
-    catch (\InvalidArgumentException $e) {
-      $this->pass('Array placeholder with scalar argument should result in an exception.');
+    catch (\Exception $e) {
+      $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
 
   }
@@ -48,7 +48,7 @@ public function testArrayArgumentsSQLInjection() {
       $this->fail('SQL injection attempt via array arguments should result in a database exception.');
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass('SQL injection attempt via array arguments should result in a database exception.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the insert query that was used in the SQL injection attempt did
@@ -85,7 +85,7 @@ public function testConditionOperatorArgumentsSQLInjection() {
       $this->fail('Should not be able to attempt SQL injection via condition operator.');
     }
     catch (\ErrorException $e) {
-      $this->pass('SQL injection attempt via condition arguments should result in a database exception.');
+      // Expected exception; just continue testing.
     }
 
     // Test that the insert query that was used in the SQL injection attempt did
@@ -113,7 +113,7 @@ public function testConditionOperatorArgumentsSQLInjection() {
       $this->fail('Should not be able to attempt SQL injection via operator.');
     }
     catch (\ErrorException $e) {
-      $this->pass('SQL injection attempt via condition arguments should result in a database exception.');
+      // Expected exception; just continue testing.
     }
 
     // Attempt SQLi via union query - uppercase tablename.
@@ -130,7 +130,7 @@ public function testConditionOperatorArgumentsSQLInjection() {
       $this->fail('Should not be able to attempt SQL injection via operator.');
     }
     catch (\ErrorException $e) {
-      $this->pass('SQL injection attempt via condition arguments should result in a database exception.');
+      // Expected exception; just continue testing.
     }
     restore_error_handler();
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
index 8caa8feff863..8dce42047143 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
@@ -433,7 +433,7 @@ public function testIndexLength() {
       $this->fail('\Drupal\Core\Database\SchemaObjectExistsException exception missed.');
     }
     catch (SchemaObjectExistsException $e) {
-      $this->pass('\Drupal\Core\Database\SchemaObjectExistsException thrown when index already exists.');
+      // Expected exception; just continue testing.
     }
 
     try {
@@ -441,7 +441,7 @@ public function testIndexLength() {
       $this->fail('\Drupal\Core\Database\SchemaObjectDoesNotExistException exception missed.');
     }
     catch (SchemaObjectDoesNotExistException $e) {
-      $this->pass('\Drupal\Core\Database\SchemaObjectDoesNotExistException thrown when index already exists.');
+      // Expected exception; just continue testing.
     }
 
     // Get index information.
@@ -687,7 +687,6 @@ protected function assertFieldAdditionRemoval($field_spec) {
       'primary key' => ['serial_column'],
     ];
     $this->schema->createTable($table_name, $table_spec);
-    $this->pass(new FormattableMarkup('Table %table created.', ['%table' => $table_name]));
 
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
@@ -705,7 +704,6 @@ protected function assertFieldAdditionRemoval($field_spec) {
       'primary key' => ['serial_column'],
     ];
     $this->schema->createTable($table_name, $table_spec);
-    $this->pass(new FormattableMarkup('Table %table created.', ['%table' => $table_name]));
 
     // Insert some rows to the table to test the handling of initial values.
     for ($i = 0; $i < 3; $i++) {
@@ -723,7 +721,6 @@ protected function assertFieldAdditionRemoval($field_spec) {
       ->execute();
 
     $this->schema->addField($table_name, 'test_field', $field_spec);
-    $this->pass(new FormattableMarkup('Column %column created.', ['%column' => 'test_field']));
 
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
@@ -1025,7 +1022,6 @@ protected function assertFieldChange($old_spec, $new_spec, $test_data = NULL) {
       'primary key' => ['serial_column'],
     ];
     $this->schema->createTable($table_name, $table_spec);
-    $this->pass(new FormattableMarkup('Table %table created.', ['%table' => $table_name]));
 
     // Check the characteristics of the field.
     $this->assertFieldCharacteristics($table_name, 'test_field', $old_spec);
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
index 7e57b5544a7e..2412797875f9 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Database\InvalidQueryException;
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\DatabaseExceptionWrapper;
 
 /**
  * Tests the Select query builder.
@@ -549,7 +550,7 @@ public function testSelectDuplicateAlias() {
   }
 
   /**
-   * Tests that an invalid merge query throws an exception.
+   * Tests that an invalid count query throws an exception.
    */
   public function testInvalidSelectCount() {
     try {
@@ -561,12 +562,9 @@ public function testInvalidSelectCount() {
         ->fields('t')
         ->countQuery()
         ->execute();
-
-      $this->pass('$options[\'throw_exception\'] is FALSE, no Exception thrown.');
     }
     catch (\Exception $e) {
       $this->fail('$options[\'throw_exception\'] is FALSE, but Exception thrown for invalid query.');
-      return;
     }
 
     try {
@@ -575,12 +573,11 @@ public function testInvalidSelectCount() {
         ->fields('t')
         ->countQuery()
         ->execute();
+      $this->fail('No Exception thrown.');
     }
     catch (\Exception $e) {
-      $this->pass('Exception thrown for invalid query.');
-      return;
+      $this->assertInstanceOf(DatabaseExceptionWrapper::class, $e);
     }
-    $this->fail('No Exception thrown.');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
index f52418ad029c..ae09e1c28134 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
@@ -268,7 +268,7 @@ public function testTransactionWithDdlStatement() {
         // $this->fail('Rolling back a transaction containing DDL should fail.');
       }
       catch (TransactionNoActiveException $e) {
-        $this->pass('Rolling back a transaction containing DDL should fail.');
+        // Expected exception; just continue testing.
       }
       $this->assertRowPresent('row');
     }
@@ -429,12 +429,12 @@ public function testTransactionStacking() {
       $this->fail('Rolling back the outer transaction while the inner transaction is active resulted in an exception.');
     }
     catch (TransactionOutOfOrderException $e) {
-      $this->pass('Rolling back the outer transaction while the inner transaction is active resulted in an exception.');
+      // Expected exception; just continue testing.
     }
     $this->assertFalse($this->connection->inTransaction(), 'No more in a transaction after rolling back the outer transaction');
     // Try to commit one inner transaction.
     unset($transaction3);
-    $this->pass('Trying to commit an inner transaction resulted in an exception.');
+
     // Try to rollback one inner transaction.
     try {
       $transaction->rollBack();
@@ -442,7 +442,7 @@ public function testTransactionStacking() {
       $this->fail('Trying to commit an inner transaction resulted in an exception.');
     }
     catch (TransactionNoActiveException $e) {
-      $this->pass('Trying to commit an inner transaction resulted in an exception.');
+      // Expected exception; just continue testing.
     }
     $this->assertRowAbsent('outer');
     $this->assertRowAbsent('inner');
@@ -459,10 +459,10 @@ public function testQueryFailureInTransaction() {
     // Test a failed query using the query() method.
     try {
       $this->connection->query('SELECT [age] FROM {test} WHERE [name] = :name', [':name' => 'David'])->fetchField();
-      $this->fail('Using the query method failed.');
+      $this->fail('Using the query method should have failed.');
     }
     catch (\Exception $e) {
-      $this->pass('Using the query method failed.');
+      // Just continue testing.
     }
 
     // Test a failed select query.
@@ -471,10 +471,10 @@ public function testQueryFailureInTransaction() {
         ->fields('test', ['name'])
         ->execute();
 
-      $this->fail('Select query failed.');
+      $this->fail('Select query should have failed.');
     }
     catch (\Exception $e) {
-      $this->pass('Select query failed.');
+      // Just continue testing.
     }
 
     // Test a failed insert query.
@@ -486,10 +486,10 @@ public function testQueryFailureInTransaction() {
         ])
         ->execute();
 
-      $this->fail('Insert query failed.');
+      $this->fail('Insert query should have failed.');
     }
     catch (\Exception $e) {
-      $this->pass('Insert query failed.');
+      // Just continue testing.
     }
 
     // Test a failed update query.
@@ -499,10 +499,10 @@ public function testQueryFailureInTransaction() {
         ->condition('id', 1)
         ->execute();
 
-      $this->fail('Update query failed.');
+      $this->fail('Update query should have failed.');
     }
     catch (\Exception $e) {
-      $this->pass('Update query failed.');
+      // Just continue testing.
     }
 
     // Test a failed delete query.
@@ -511,10 +511,10 @@ public function testQueryFailureInTransaction() {
         ->condition('id', 1)
         ->execute();
 
-      $this->fail('Delete query failed.');
+      $this->fail('Delete query should have failed.');
     }
     catch (\Exception $e) {
-      $this->pass('Delete query failed.');
+      // Just continue testing.
     }
 
     // Test a failed merge query.
@@ -527,10 +527,10 @@ public function testQueryFailureInTransaction() {
         ])
         ->execute();
 
-      $this->fail('Merge query failed.');
+      $this->fail('Merge query should have failed.');
     }
     catch (\Exception $e) {
-      $this->pass('Merge query failed.');
+      // Just continue testing.
     }
 
     // Test a failed upsert query.
@@ -545,10 +545,10 @@ public function testQueryFailureInTransaction() {
         ])
         ->execute();
 
-      $this->fail('Upset query failed.');
+      $this->fail('Upsert query should have failed.');
     }
     catch (\Exception $e) {
-      $this->pass('Upset query failed.');
+      // Just continue testing.
     }
 
     // Create the missing schema and insert a row.
diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
index 832c9b1d81fc..86d78bfb9b80 100644
--- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
+++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
@@ -4,6 +4,7 @@
 
 use Composer\Autoload\ClassLoader;
 use Drupal\Core\DrupalKernel;
+use Drupal\Core\DrupalKernelInterface;
 use Drupal\KernelTests\KernelTestBase;
 use org\bovigo\vfs\vfsStream;
 use Prophecy\Argument;
@@ -160,10 +161,8 @@ public function testRepeatedBootWithDifferentEnvironment() {
       $kernel = DrupalKernel::createFromRequest($request, $class_loader, $environment);
       $this->setSetting('container_yamls', []);
       $this->setSetting('hash_salt', $this->databasePrefix);
-      $kernel->boot();
+      $this->assertInstanceOf(DrupalKernelInterface::class, $kernel->boot(), "Environment $environment should boot.");
     }
-
-    $this->pass('Repeatedly loaded compiled DIC with different environment');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
index 3bebe79b97b1..6b8e5149432c 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
@@ -214,7 +214,6 @@ public function testEntityStorageExceptionHandling() {
     try {
       unset($GLOBALS['entity_test_throw_exception']);
       $entity->save();
-      $this->pass('Exception presave not thrown and not caught.');
     }
     catch (EntityStorageException $e) {
       $this->assertNotEqual($e->getCode(), 1, 'Entity presave EntityStorageException caught.');
@@ -236,7 +235,6 @@ public function testEntityStorageExceptionHandling() {
     $entity->save();
     try {
       $entity->delete();
-      $this->pass('Entity predelete EntityStorageException not thrown and not caught.');
     }
     catch (EntityStorageException $e) {
       $this->assertNotEqual($e->getCode(), 2, 'Entity predelete EntityStorageException thrown.');
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php
index 133a2f03592c..b8b9d670a7e1 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php
@@ -115,7 +115,7 @@ public function testSelectionSettingsHandling() {
       $this->fail('Non-existent selection settings key throws an exception.');
     }
     catch (AccessDeniedHttpException $e) {
-      $this->pass('Non-existent selection settings key throws an exception.');
+      // Expected exception; just continue testing.
     }
 
     try {
@@ -129,12 +129,7 @@ public function testSelectionSettingsHandling() {
       $entity_reference_controller->handleAutocomplete($request, $this->entityType, 'default', $selection_settings_key);
     }
     catch (AccessDeniedHttpException $e) {
-      if ($e->getMessage() == 'Invalid selection settings key.') {
-        $this->pass('Invalid selection settings key throws an exception.');
-      }
-      else {
-        $this->fail('Invalid selection settings key throws an exception.');
-      }
+      $this->assertSame('Invalid selection settings key.', $e->getMessage());
     }
 
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
index 5c4fd427345f..c829d7b40cd6 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
@@ -550,7 +550,7 @@ public function testEntityRollback() {
       $this->fail('Expected exception has not been thrown.');
     }
     catch (\Exception $e) {
-      $this->pass('Expected exception has been thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Check that the block does not exist in the database.
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php
index 1d95a657f8f3..c4222817edc6 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php
@@ -144,7 +144,7 @@ public function testEntityTypeUpdateWithEntityStorageChange() {
       $this->fail('EntityStorageException thrown when trying to apply an update that requires shared table schema changes.');
     }
     catch (EntityStorageException $e) {
-      $this->pass('EntityStorageException thrown when trying to apply an update that requires shared table schema changes.');
+      // Expected exception; just continue testing.
     }
   }
 
@@ -426,7 +426,6 @@ public function testBaseFieldCreateDeleteWithExistingEntities() {
     $this->assertTrue($assert, 'Columns created again in shared table for new_base_field.');
     $entity = $storage->create(['name' => $name]);
     $entity->save();
-    $this->pass('The new_base_field columns are still nullable');
   }
 
   /**
@@ -490,7 +489,6 @@ public function testBundleFieldCreateDeleteWithExistingEntities() {
         $this->database->insert('entity_test_update__new_bundle_field')
           ->fields($values)
           ->execute();
-        $this->pass($message);
       }
       else {
         // Keep throwing it.
@@ -763,7 +761,7 @@ public function testBaseFieldUpdateWithExistingData() {
       $this->fail('FieldStorageDefinitionUpdateForbiddenException thrown when trying to update a field schema that has data.');
     }
     catch (FieldStorageDefinitionUpdateForbiddenException $e) {
-      $this->pass('FieldStorageDefinitionUpdateForbiddenException thrown when trying to update a field schema that has data.');
+      // Expected exception; just continue testing.
     }
   }
 
@@ -787,7 +785,7 @@ public function testBundleFieldUpdateWithExistingData() {
       $this->fail('FieldStorageDefinitionUpdateForbiddenException thrown when trying to update a field schema that has data.');
     }
     catch (FieldStorageDefinitionUpdateForbiddenException $e) {
-      $this->pass('FieldStorageDefinitionUpdateForbiddenException thrown when trying to update a field schema that has data.');
+      // Expected exception; just continue testing.
     }
   }
 
@@ -972,7 +970,7 @@ public function testSingleActionCalls() {
       $this->fail($message);
     }
     catch (PluginNotFoundException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Ensure that a field cannot be installed on non-existing entity type.
@@ -985,7 +983,7 @@ public function testSingleActionCalls() {
       $this->fail($message);
     }
     catch (PluginNotFoundException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Ensure that installing an existing entity type is a no-op.
@@ -1114,14 +1112,13 @@ public function testBaseFieldEntityKeyUpdateWithExistingData() {
       $this->fail($message);
     }
     catch (EntityStorageException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Check that the update is correctly applied when no NULL data is left.
     $entity->set('new_base_field', $this->randomString());
     $entity->save();
     $this->applyEntityUpdates();
-    $this->pass('The update is correctly performed when no NULL data exists.');
 
     // Check that the update actually applied a NOT NULL constraint.
     $entity->set('new_base_field', NULL);
@@ -1131,7 +1128,7 @@ public function testBaseFieldEntityKeyUpdateWithExistingData() {
       $this->fail($message);
     }
     catch (EntityStorageException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
   }
 
@@ -1269,7 +1266,6 @@ public function testInitialValueFromFieldErrorHandling() {
     }
     catch (FieldException $e) {
       $this->assertEquals('Illegal initial value definition on new_base_field: The field field_that_does_not_exist does not exist.', $e->getMessage());
-      $this->pass('Using a non-existent field as initial value does not work.');
     }
 
     try {
@@ -1282,7 +1278,6 @@ public function testInitialValueFromFieldErrorHandling() {
     }
     catch (FieldException $e) {
       $this->assertEquals('Illegal initial value definition on new_base_field: The field types do not match.', $e->getMessage());
-      $this->pass('Using a field of a different type as initial value does not work.');
     }
 
     try {
@@ -1306,7 +1301,6 @@ public function testInitialValueFromFieldErrorHandling() {
     }
     catch (FieldException $e) {
       $this->assertEquals('Illegal initial value definition on new_base_field: Both fields have to be stored in the shared entity tables.', $e->getMessage());
-      $this->pass('Using a field that is not stored in the shared tables as initial value does not work.');
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
index d0bf76dfc5ae..380f5b5263a9 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
@@ -1106,17 +1106,12 @@ public function testPendingRevisions() {
    * database driver's EntityQuery\Condition class.
    */
   public function testInjectionInCondition() {
-    try {
-      $this->queryResults = $this->storage
-        ->getQuery()
-        ->condition('1 ; -- ', [0, 1], 'IN')
-        ->sort('id')
-        ->execute();
-      $this->fail('SQL Injection attempt in Entity Query condition in operator should result in an exception.');
-    }
-    catch (\Exception $e) {
-      $this->pass('SQL Injection attempt in Entity Query condition in operator should result in an exception.');
-    }
+    $this->expectException(\Exception::class);
+    $this->queryResults = $this->storage
+      ->getQuery()
+      ->condition('1 ; -- ', [0, 1], 'IN')
+      ->sort('id')
+      ->execute();
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
index 3c7faa510e46..a219ac38ac4d 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
@@ -273,7 +273,7 @@ public function testAutocreateApi() {
       $this->fail($message);
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
     $this->assertUserAutocreate($entity, function (EntityInterface $entity, UserInterface $user) {
       $entity->user_id = $user;
@@ -307,7 +307,7 @@ public function testAutocreateApi() {
       $this->fail($message);
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
     $this->assertUserRoleAutocreate($entity, function (EntityInterface $entity, RoleInterface $role) {
       $entity->user_role = $role;
@@ -404,7 +404,6 @@ public function testTargetEntityNoLoad() {
         ->getStorage($entity_type->id())
         ->create(['name' => $this->randomString()]);
       $entity->target_reference = $target_id;
-      $this->pass($message);
     }
     catch (EntityStorageException $e) {
       $this->fail($message);
@@ -418,7 +417,7 @@ public function testTargetEntityNoLoad() {
       $this->fail($message);
     }
     catch (EntityStorageException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
index a7426b84d081..506f1f458aa8 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
@@ -62,13 +62,12 @@ protected function doTestEntityLanguageMethods($entity_type) {
     $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, new FormattableMarkup('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type]));
 
     // Try to get add a translation to language neutral entity.
-    $message = 'Adding a translation to a language-neutral entity results in an error.';
     try {
       $entity->addTranslation($this->langcodes[1]);
-      $this->fail($message);
+      $this->fail('Adding a translation to a language-neutral entity results in an error.');
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Now, make the entity language-specific by assigning a language and test
@@ -101,26 +100,24 @@ protected function doTestEntityLanguageMethods($entity_type) {
     $this->assertEqual($entity->getTranslationLanguages(FALSE), $translations, 'Translations retrieved.');
 
     // Try to get a value using a language code for a non-existing translation.
-    $message = 'Getting a non existing translation results in an error.';
     try {
       $entity->getTranslation($this->langcodes[2])->get($this->fieldName)->value;
-      $this->fail($message);
+      $this->fail('Getting a non existing translation results in an error.');
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Try to get a not available translation.
     $this->assertNull($entity->addTranslation($this->langcodes[2])->get($this->fieldName)->value, new FormattableMarkup('%entity_type: A translation that is not available is NULL.', ['%entity_type' => $entity_type]));
 
     // Try to get a value using an invalid language code.
-    $message = 'Getting an invalid translation results in an error.';
     try {
       $entity->getTranslation('invalid')->get($this->fieldName)->value;
-      $this->fail($message);
+      $this->fail('Getting an invalid translation results in an error.');
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Try to set a value using an invalid language code.
@@ -129,7 +126,7 @@ protected function doTestEntityLanguageMethods($entity_type) {
       $this->fail(new FormattableMarkup('%entity_type: Setting a translation for an invalid language throws an exception.', ['%entity_type' => $entity_type]));
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass(new FormattableMarkup('%entity_type: Setting a translation for an invalid language throws an exception.', ['%entity_type' => $entity_type]));
+      // Expected exception; just continue testing.
     }
 
     // Set the value in default language.
@@ -352,13 +349,12 @@ protected function doTestEntityTranslationAPI($entity_type) {
 
     // Verify that trying to retrieve a translation for a locked language when
     // the entity is language-aware causes an exception to be thrown.
-    $message = 'A language-neutral translation cannot be retrieved.';
     try {
       $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED);
-      $this->fail($message);
+      $this->fail('A language-neutral translation cannot be retrieved.');
     }
     catch (\LogicException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Create a translation and verify that the translation object and the
@@ -391,23 +387,20 @@ protected function doTestEntityTranslationAPI($entity_type) {
 
     // Verify that changing translation language causes an exception to be
     // thrown.
-    $message = 'The translation language cannot be changed.';
     try {
       $translation->{$langcode_key}->value = $this->langcodes[2];
-      $this->fail($message);
+      $this->fail('The translation language cannot be changed.');
     }
     catch (\LogicException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
 
     // Verify that reassigning the same translation language is allowed.
-    $message = 'The translation language can be reassigned the same value.';
     try {
       $translation->{$langcode_key}->value = $langcode;
-      $this->pass($message);
     }
     catch (\LogicException $e) {
-      $this->fail($message);
+      $this->fail('The translation language can be reassigned the same value.');
     }
 
     // Verify that changing the default translation flag causes an exception to
@@ -416,22 +409,19 @@ protected function doTestEntityTranslationAPI($entity_type) {
       $translation = $entity->getTranslation($t_langcode);
       $default = $translation->isDefaultTranslation();
 
-      $message = 'The default translation flag can be reassigned the same value.';
       try {
         $translation->{$default_langcode_key}->value = $default;
-        $this->pass($message);
       }
       catch (\LogicException $e) {
-        $this->fail($message);
+        $this->fail('The default translation flag can be reassigned the same value.');
       }
 
-      $message = 'The default translation flag cannot be changed.';
       try {
         $translation->{$default_langcode_key}->value = !$default;
-        $this->fail($message);
+        $this->fail('The default translation flag cannot be changed.');
       }
       catch (\LogicException $e) {
-        $this->pass($message);
+        // Expected exception; just continue testing.
       }
 
       $this->assertEqual($translation->{$default_langcode_key}->value, $default);
@@ -464,13 +454,12 @@ protected function doTestEntityTranslationAPI($entity_type) {
     $translation = $entity->getTranslation($langcode2);
     $entity->removeTranslation($langcode2);
     foreach (['get', 'set', '__get', '__set', 'createDuplicate'] as $method) {
-      $message = new FormattableMarkup('The @method method raises an exception when trying to manipulate a removed translation.', ['@method' => $method]);
       try {
         $translation->{$method}('name', $this->randomMachineName());
-        $this->fail($message);
+        $this->fail("The $method method raises an exception when trying to manipulate a removed translation.");
       }
       catch (\Exception $e) {
-        $this->pass($message);
+        // Expected exception; just continue testing.
       }
     }
 
@@ -486,13 +475,12 @@ protected function doTestEntityTranslationAPI($entity_type) {
     // Check that removing an invalid translation causes an exception to be
     // thrown.
     foreach ([$default_langcode, LanguageInterface::LANGCODE_DEFAULT, $this->randomMachineName()] as $invalid_langcode) {
-      $message = new FormattableMarkup('Removing an invalid translation (@langcode) causes an exception to be thrown.', ['@langcode' => $invalid_langcode]);
       try {
         $entity->removeTranslation($invalid_langcode);
-        $this->fail($message);
+        $this->fail("Removing an invalid translation ($invalid_langcode) causes an exception to be thrown.");
       }
       catch (\Exception $e) {
-        $this->pass($message);
+        // Expected exception; just continue testing.
       }
     }
 
@@ -714,14 +702,13 @@ public function testFieldDefinitions() {
     foreach ($translatable_fields as $name => $translatable) {
       $this->state->set('entity_test.field_definitions.translatable', [$name => $translatable]);
       $entity_field_manager->clearCachedFieldDefinitions();
-      $message = new FormattableMarkup('Field %field cannot be translatable.', ['%field' => $name]);
 
       try {
         $entity_field_manager->getBaseFieldDefinitions($entity_type);
-        $this->fail($message);
+        $this->fail("Field $name cannot be translatable.");
       }
       catch (\LogicException $e) {
-        $this->pass($message);
+        // Expected exception; just continue testing.
       }
     }
   }
@@ -778,13 +765,12 @@ protected function doTestLanguageChange($entity_type) {
 
     // Check that setting the default language to an existing translation
     // language causes an exception to be thrown.
-    $message = 'An exception is thrown when setting the default language to an existing translation language';
     try {
       $entity->{$langcode_key}->value = $this->langcodes[2];
-      $this->fail($message);
+      $this->fail('An exception is thrown when setting the default language to an existing translation language');
     }
     catch (\InvalidArgumentException $e) {
-      $this->pass($message);
+      // Expected exception; just continue testing.
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
index 58ab32abdb41..0ad3dd9c98fe 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php
@@ -340,13 +340,8 @@ public function testUpdateFieldSchemaWithData() {
 
     // Attempt to update the field in a way that would work without data.
     $field_storage->setSetting('scale', 3);
-    try {
-      $field_storage->save();
-      $this->fail('Cannot update field schema with data.');
-    }
-    catch (FieldStorageDefinitionUpdateForbiddenException $e) {
-      $this->pass('Cannot update field schema with data.');
-    }
+    $this->expectException(FieldStorageDefinitionUpdateForbiddenException::class);
+    $field_storage->save();
   }
 
   /**
@@ -374,7 +369,7 @@ public function testFieldUpdateFailure() {
       $this->fail('Update succeeded.');
     }
     catch (\Exception $e) {
-      $this->pass('Update properly failed.');
+      // Expected exception; just continue testing.
     }
 
     // Ensure that the field tables are still there.
diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php
index 7360045d2dcc..67aa2b249fc7 100644
--- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php
@@ -77,15 +77,10 @@ public function testModuleImplementsAlterNonExistingImplementation() {
     // Install the module_test module.
     \Drupal::service('module_installer')->install(['module_test']);
 
-    try {
-      // Trigger hook discovery.
-      \Drupal::moduleHandler()->getImplementations('unimplemented_test_hook');
-      $this->fail('An exception should be thrown for the non-existing implementation.');
-    }
-    catch (\RuntimeException $e) {
-      $this->pass('An exception should be thrown for the non-existing implementation.');
-      $this->assertEqual($e->getMessage(), 'An invalid implementation module_test_unimplemented_test_hook was added by hook_module_implements_alter()');
-    }
+    // Trigger hook discovery.
+    $this->expectException(\RuntimeException::class);
+    $this->expectExceptionMessage('An invalid implementation module_test_unimplemented_test_hook was added by hook_module_implements_alter()');
+    \Drupal::moduleHandler()->getImplementations('unimplemented_test_hook');
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php
index ade5d167a2c8..af905e678df2 100644
--- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php
@@ -62,7 +62,7 @@ public function testCRUD() {
       $this->fail('EntityMalformedException was thrown.');
     }
     catch (EntityMalformedException $e) {
-      $this->pass('EntityMalformedException was thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Verify that an empty entity cannot be saved.
@@ -71,7 +71,7 @@ public function testCRUD() {
       $this->fail('EntityMalformedException was thrown.');
     }
     catch (EntityMalformedException $e) {
-      $this->pass('EntityMalformedException was thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Verify that an entity with an empty ID string is considered empty, too.
@@ -84,7 +84,7 @@ public function testCRUD() {
       $this->fail('EntityMalformedException was thrown.');
     }
     catch (EntityMalformedException $e) {
-      $this->pass('EntityMalformedException was thrown.');
+      // Expected exception; just continue testing.
     }
 
     // Verify properties on a newly created entity.
@@ -108,7 +108,6 @@ public function testCRUD() {
     // Verify that the entity can be saved.
     try {
       $status = $entity_test->save();
-      $this->pass('EntityMalformedException was not thrown.');
     }
     catch (EntityMalformedException $e) {
       $this->fail('EntityMalformedException was not thrown.');
@@ -143,7 +142,7 @@ public function testCRUD() {
       $this->fail('Not possible to overwrite an entity entity.');
     }
     catch (EntityStorageException $e) {
-      $this->pass('Not possible to overwrite an entity entity.');
+      // Expected exception; just continue testing.
     }
 
     // Verify that renaming the ID returns correct status and properties.
diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
index fe3d057feb9e..5c2b9ba1f5da 100644
--- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
@@ -214,7 +214,7 @@ public function testMenuDisabledChildLinks() {
       $this->fail('Exception was not thrown');
     }
     catch (PluginException $e) {
-      $this->pass($e->getMessage());
+      // Expected exception; just continue testing.
     }
     // The opposite move should work, and change the has_children flag.
     $this->moveMenuLink('footerA', 'test1');
@@ -354,7 +354,6 @@ public function testLoadByProperties() {
       }
       catch (\InvalidArgumentException $e) {
         $this->assertRegExp('/^An invalid property name, .+ was specified. Allowed property names are:/', $e->getMessage(), 'Found expected exception message.');
-        $this->pass($message);
       }
     }
     $this->addMenuLink('test_link.1', '', 'test', [], 'menu1');
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php
index 0178bb546ab0..844fb43e0ab5 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/FactoryTest.php
@@ -31,11 +31,8 @@ public function testDefaultFactory() {
       $this->testPluginManager->createInstance('non_existing');
       $this->fail('Drupal\Component\Plugin\Exception\ExceptionInterface expected');
     }
-    catch (ExceptionInterface $e) {
-      $this->pass('Drupal\Component\Plugin\Exception\ExceptionInterface expected and caught.');
-    }
     catch (\Exception $e) {
-      $this->fail('Drupal\Component\Plugin\Exception\ExceptionInterface expected, but ' . get_class($e) . ' was thrown.');
+      $this->assertInstanceOf(ExceptionInterface::class, $e);
     }
   }
 
@@ -68,11 +65,8 @@ public function testReflectionFactory() {
         $this->mockBlockManager->createInstance($invalid_id);
         $this->fail('Drupal\Component\Plugin\Exception\ExceptionInterface expected');
       }
-      catch (ExceptionInterface $e) {
-        $this->pass('Drupal\Component\Plugin\Exception\ExceptionInterface expected and caught.');
-      }
       catch (\Exception $e) {
-        $this->fail('An unexpected Exception of type "' . get_class($e) . '" was thrown with message ' . $e->getMessage());
+        $this->assertInstanceOf(ExceptionInterface::class, $e);
       }
     }
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php b/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php
index f35f310dd3b6..17a950be9173 100644
--- a/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php
@@ -68,13 +68,8 @@ public function testProcessAttached() {
     $build['#attached']['library'][] = 'core/drupal.states';
     $build['#attached']['drupal_process_states'][] = [];
     $renderer = $this->container->get('bare_html_page_renderer');
-    try {
-      $renderer->renderBarePage($build, '', 'maintenance_page');
-      $this->fail("Invalid #attachment 'drupal_process_states' allowed");
-    }
-    catch (\LogicException $e) {
-      $this->pass("Invalid #attachment 'drupal_process_states' not allowed");
-    }
+    $this->expectException(\LogicException::class);
+    $renderer->renderBarePage($build, '', 'maintenance_page');
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php
index 9c38b90daa39..88600c9878e2 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php
@@ -136,17 +136,13 @@ public function testFullNegotiation() {
       $path = $test[0];
       $accept_header = $test[1];
       $content_type = $test[2];
-      $message = "Testing path:$path Accept:$accept_header Content-type:$content_type";
       $request = Request::create('/' . $path);
       $request->headers->set('Accept', $accept_header);
 
       /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $kernel */
       $kernel = \Drupal::getContainer()->get('http_kernel');
       $response = $kernel->handle($request);
-      // Verbose message since simpletest doesn't let us provide a message and
-      // see the error.
-      $this->pass($message);
-      $this->assertEqual($response->getStatusCode(), Response::HTTP_OK);
+      $this->assertEqual($response->getStatusCode(), Response::HTTP_OK, "Testing path:$path Accept:$accept_header Content-type:$content_type");
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php b/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php
index b86eef6e411f..41873110a43a 100644
--- a/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php
@@ -95,16 +95,8 @@ public function testAddAdditionalRoutes() {
     $dumper_routes = $dumper->getRoutes()->all();
     $collection_routes = $collection->all();
 
-    $success = TRUE;
     foreach ($collection_routes as $name => $route) {
-      if (empty($dumper_routes[$name])) {
-        $success = FALSE;
-        $this->fail('Not all routes found in the dumper.');
-      }
-    }
-
-    if ($success) {
-      $this->pass('All routes found in the dumper.');
+      $this->assertNotEmpty($dumper_routes[$name], "Route $name should be present in the dumper.");
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php b/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php
index 0492d773475c..81e5291d985c 100644
--- a/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php
@@ -50,18 +50,9 @@ public function testAccountSwitching() {
 
     // Verify that AccountSwitcherInterface::switchBack() will throw
     // an exception if there are no accounts left in the stack.
-    try {
-      $switcher->switchBack();
-      $this->fail('::switchBack() throws exception if called without previous switch.');
-    }
-    catch (\RuntimeException $e) {
-      if ($e->getMessage() == 'No more accounts to revert to.') {
-        $this->pass('::switchBack() throws exception if called without previous switch.');
-      }
-      else {
-        $this->fail($e->getMessage());
-      }
-    }
+    $this->expectException(\RuntimeException::class);
+    $this->expectExceptionMessage('No more accounts to revert to.');
+    $switcher->switchBack();
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php
index eda533ad2927..7973648f62d0 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php
@@ -115,8 +115,8 @@ public function testInstallNonExisting() {
       $this->themeInstaller()->install([$name]);
       $this->fail($message);
     }
-    catch (UnknownExtensionException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+    catch (\Exception $e) {
+      $this->assertInstanceOf(UnknownExtensionException::class, $e);
     }
 
     $themes = $this->themeHandler()->listInfo();
@@ -134,8 +134,8 @@ public function testInstallNameTooLong() {
       $this->themeInstaller()->install([$name]);
       $this->fail($message);
     }
-    catch (ExtensionNameLengthException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+    catch (\Exception $e) {
+      $this->assertInstanceOf(ExtensionNameLengthException::class, $e);
     }
   }
 
@@ -230,8 +230,8 @@ public function testUninstallDefault() {
       $this->themeInstaller()->uninstall([$name]);
       $this->fail($message);
     }
-    catch (\InvalidArgumentException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+    catch (\Exception $e) {
+      $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
 
     $themes = $this->themeHandler()->listInfo();
@@ -257,8 +257,8 @@ public function testUninstallAdmin() {
       $this->themeInstaller()->uninstall([$name]);
       $this->fail($message);
     }
-    catch (\InvalidArgumentException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+    catch (\Exception $e) {
+      $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
 
     $themes = $this->themeHandler()->listInfo();
@@ -295,8 +295,8 @@ public function testUninstallBaseBeforeSubTheme() {
       $this->themeInstaller()->uninstall([$name]);
       $this->fail($message);
     }
-    catch (\InvalidArgumentException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+    catch (\Exception $e) {
+      $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
 
     $themes = $this->themeHandler()->listInfo();
@@ -325,8 +325,8 @@ public function testUninstallNonExisting() {
       $this->themeInstaller()->uninstall([$name]);
       $this->fail($message);
     }
-    catch (UnknownExtensionException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+    catch (\Exception $e) {
+      $this->assertInstanceOf(UnknownExtensionException::class, $e);
     }
 
     $themes = $this->themeHandler()->listInfo();
@@ -367,8 +367,8 @@ public function testUninstallNotInstalled() {
       $this->themeInstaller()->uninstall([$name]);
       $this->fail($message);
     }
-    catch (UnknownExtensionException $e) {
-      $this->pass(get_class($e) . ': ' . $e->getMessage());
+    catch (\Exception $e) {
+      $this->assertInstanceOf(UnknownExtensionException::class, $e);
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
index 345d31075cf7..196e94fe0c9f 100644
--- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
+++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
@@ -428,7 +428,7 @@ public function testTypedDataLists() {
       $this->fail('No exception has been thrown when setting an invalid value.');
     }
     catch (\Exception $e) {
-      $this->pass('Exception thrown:' . $e->getMessage());
+      // Expected exception; just continue testing.
     }
   }
 
@@ -550,7 +550,7 @@ public function testTypedDataMaps() {
       $this->fail('No exception has been thrown when getting an invalid value.');
     }
     catch (\Exception $e) {
-      $this->pass('Exception thrown:' . $e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     // Test setting invalid values.
@@ -559,7 +559,7 @@ public function testTypedDataMaps() {
       $this->fail('No exception has been thrown when setting an invalid value.');
     }
     catch (\Exception $e) {
-      $this->pass('Exception thrown:' . $e->getMessage());
+      // Expected exception; just continue testing.
     }
 
     // Test adding a new property to the map.
diff --git a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
index 5b47a987f877..cd831e212ebd 100644
--- a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
+++ b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
@@ -216,6 +216,14 @@ public function testAssertElementNotPresent() {
     $this->assertElementNotPresent('.pager');
   }
 
+  /**
+   * @covers ::pass
+   * @expectedDeprecation AssertLegacyTrait::pass() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. PHPUnit interrupts a test as soon as a test assertion fails, so there is usually no need to call this method. If a test's logic relies on this method, refactor the test. See https://www.drupal.org/node/3129738
+   */
+  public function testPass() {
+    $this->pass('Passed.');
+  }
+
   /**
    * Returns a mocked behat session object.
    *
diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
index 8b6ec6b62171..88728ea1f5d5 100644
--- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -169,7 +169,6 @@ public static function getSkippedDeprecations() {
       'AssertLegacyTrait::assertNotEqual() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertNotEquals() instead. See https://www.drupal.org/node/3129738',
       'AssertLegacyTrait::assertIdentical() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertSame() instead. See https://www.drupal.org/node/3129738',
       'AssertLegacyTrait::assertNotIdentical() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertNotSame() instead. See https://www.drupal.org/node/3129738',
-      'AssertLegacyTrait::pass() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. PHPUnit interrupts a test as soon as a test assertion fails, so there is usually no need to call this method. If a test\'s logic relies on this method, refactor the test. See https://www.drupal.org/node/3129738',
       'AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738',
       'AssertLegacyTrait::assertNoText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738',
       'AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->pageTextContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738',
-- 
GitLab