diff --git a/core/modules/file/tests/src/Functional/FileManagedTestBase.php b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
index f219a934b766edf9807b66718dff48e5538f56d2..252a73822143025a0a8c1a18c2ff03a4af3813d1 100644
--- a/core/modules/file/tests/src/Functional/FileManagedTestBase.php
+++ b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
@@ -4,7 +4,6 @@
 
 namespace Drupal\Tests\file\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\file\Entity\File;
 use Drupal\file\FileInterface;
 use Drupal\Tests\BrowserTestBase;
@@ -75,13 +74,13 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
-        $message = new FormattableMarkup('hook_file_@name was called correctly.', ['@name' => $hook]);
+        $message = "hook_file_$hook was called correctly.";
       }
       elseif ($expected_count == 0) {
-        $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]);
+        $message = "hook_file_$hook was not expected to be called but was actually called $actual_count time(s).";
       }
       else {
-        $message = new FormattableMarkup('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]);
+        $message = "hook_file_$hook was expected to be called $expected_count time(s) but was called $actual_count time(s).";
       }
     }
     $this->assertEquals($expected_count, $actual_count, $message);
diff --git a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
index 69fa3b41134fb10fcbd5dc191ae01c582698955d..96d9fbb06abde2223f418deb52278452009730d7 100644
--- a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
+++ b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
@@ -4,7 +4,6 @@
 
 namespace Drupal\Tests\file\Kernel;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\file\Entity\File;
 use Drupal\file\FileInterface;
 use Drupal\KernelTests\KernelTestBase;
@@ -88,16 +87,16 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
-        $message = new FormattableMarkup('hook_file_@name was called correctly.', ['@name' => $hook]);
+        $message = "hook_file_$hook was called correctly.";
       }
       elseif ($expected_count == 0) {
-        $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]);
+        $message = "hook_file_$hook was not expected to be called but was actually called $actual_count time(s).";
       }
       else {
-        $message = new FormattableMarkup('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]);
+        $message = "hook_file_$hook was expected to be called $expected_count time(s) but was called $actual_count time(s).";
       }
     }
-    $this->assertEquals($expected_count, $actual_count, (string) $message);
+    $this->assertEquals($expected_count, $actual_count, $message);
   }
 
   /**