diff --git a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php
index ba69bfee60..8fff843319 100644
--- a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php
+++ b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php
@@ -33,7 +33,7 @@ public function testNonHtmlResponse($response_class) {
     $big_pipe_response_attachments_processor = $this->createBigPipeResponseAttachmentsProcessor($this->prophesize(AttachmentsResponseProcessorInterface::class));
 
     $non_html_response = new $response_class();
-    $this->setExpectedException(\AssertionError::class);
+    $this->setExpectedAssertion();
     $big_pipe_response_attachments_processor->processAttachments($non_html_response);
   }
 
diff --git a/core/tests/Drupal/Tests/AssertHelperTrait.php b/core/tests/Drupal/Tests/AssertHelperTrait.php
index ba814d9641..d6aae1caac 100644
--- a/core/tests/Drupal/Tests/AssertHelperTrait.php
+++ b/core/tests/Drupal/Tests/AssertHelperTrait.php
@@ -32,4 +32,24 @@ protected static function castSafeStrings($value) {
     return $value;
   }
 
+  /**
+   * Expect an assertion to failure.
+   *
+   * @param string $message
+   *   Option failure message.
+   */
+  protected function setExpectedAssertion($message = '') {
+    if (ini_get('zend.assertions') != 1) {
+      $this->markTestSkipped(
+        'Assertions are not enabled. Set zend.assertions to 1 to run this test.'
+      );
+    }
+    elseif (method_exists($this, 'expectException')) {
+      $this->expectException(\AssertionError::class, $message);
+    }
+    else {
+      $this->setExpectedException(\AssertionError::class, $message);
+    }
+  }
+
 }
diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
index a8a8af0e6c..11e93d2777 100644
--- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
@@ -343,7 +343,12 @@ public function testTransformRootRelativeUrlsToAbsolute($html, $scheme_and_host,
    * @dataProvider providerTestTransformRootRelativeUrlsToAbsoluteAssertion
    */
   public function testTransformRootRelativeUrlsToAbsoluteAssertion($scheme_and_host) {
-    if (method_exists($this, 'expectException')) {
+    if (ini_get('zend.assertions') != 1) {
+      $this->markTestSkipped(
+        'Assertions are not enabled. Set zend.assertions to 1 to run this test.'
+      );
+    }
+    elseif (method_exists($this, 'expectException')) {
       $this->expectException(\AssertionError::class);
     }
     else {
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
index cbb06668c0..221fd683b2 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
@@ -528,7 +528,7 @@ public function testCssAssert($extension, $exception_message) {
     $path = substr($path, strlen($this->root) + 1);
     $this->libraryDiscoveryParser->setPaths('module', $extension, $path);
 
-    $this->setExpectedException(\AssertionError::class, $exception_message);
+    $this->setExpectedAssertion($exception_message);
     $this->libraryDiscoveryParser->buildByExtension($extension);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
index 5466a098ab..e973ab7abf 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php
@@ -17,7 +17,7 @@ class CacheTagsInvalidatorTest extends UnitTestCase {
    */
   public function testInvalidateTagsWithInvalidTags() {
     $cache_tags_invalidator = new CacheTagsInvalidator();
-    $this->setExpectedException(\AssertionError::class);
+    $this->setExpectedAssertion();
     $cache_tags_invalidator->invalidateTags(['node' => [2, 3, 5, 8, 13]]);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
index f89e639cc7..34ea6619ac 100644
--- a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
@@ -110,7 +110,7 @@ public function testInvalidContext() {
     $container = $this->getMockContainer();
     $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
 
-    $this->setExpectedException(\AssertionError::class);
+    $this->setExpectedAssertion();
     $cache_contexts_manager->convertTokensToKeys(["non-cache-context"]);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php
index 6631479e0a..f09115eb3a 100644
--- a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php
@@ -46,7 +46,7 @@ public function testRegisterException() {
    */
   public function testSerialize() {
     $container = new ContainerBuilder();
-    $this->setExpectedException(\AssertionError::class);
+    $this->setExpectedAssertion();
     serialize($container);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php
index a0c936f85c..49eb9e33d3 100644
--- a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php
+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php
@@ -16,7 +16,7 @@ class ContainerTest extends UnitTestCase {
    */
   public function testSerialize() {
     $container = new Container();
-    $this->setExpectedException(\AssertionError::class);
+    $this->setExpectedAssertion();
     serialize($container);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php b/core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php
index 776b79446d..0295a58ed9 100644
--- a/core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php
@@ -128,7 +128,7 @@ public function testProcessPlaceholdersNoStrategies() {
     ];
 
     $chained_placeholder_strategy = new ChainedPlaceholderStrategy();
-    $this->setExpectedException(\AssertionError::class, 'At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.');
+    $this->setExpectedAssertion('At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.');
     $chained_placeholder_strategy->processPlaceholders($placeholders);
   }
 
@@ -152,7 +152,7 @@ public function testProcessPlaceholdersWithRoguePlaceholderStrategy() {
 
     $chained_placeholder_strategy = new ChainedPlaceholderStrategy();
     $chained_placeholder_strategy->addPlaceholderStrategy($rogue_strategy);
-    $this->setExpectedException(\AssertionError::class, 'Processed placeholders must be a subset of all placeholders.');
+    $this->setExpectedAssertion('Processed placeholders must be a subset of all placeholders.');
     $chained_placeholder_strategy->processPlaceholders($placeholders);
   }
 
diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php
index 58173e540f..f554087ae2 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -18,6 +18,7 @@
 abstract class UnitTestCase extends TestCase {
 
   use PhpunitCompatibilityTrait;
+  use AssertHelperTrait;
 
   /**
    * The random generator.
