diff --git a/core/tests/Drupal/KernelTests/AssertLegacyTrait.php b/core/tests/Drupal/KernelTests/AssertLegacyTrait.php
index f63c4bf..d0bd625 100644
--- a/core/tests/Drupal/KernelTests/AssertLegacyTrait.php
+++ b/core/tests/Drupal/KernelTests/AssertLegacyTrait.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\KernelTests;
 
+use Drupal\Tests\BrowserTestBase;
+
 /**
  * Translates Simpletest assertion methods to PHPUnit.
  *
@@ -114,10 +116,11 @@ protected function pass($message) {
    * @see \Drupal\simpletest\TestBase::verbose()
    */
   protected function verbose($message) {
-    if (in_array('--debug', $_SERVER['argv'], TRUE)) {
-      // Write directly to STDOUT to not produce unexpected test output.
-      // The STDOUT stream does not obey output buffering.
-      fwrite(STDOUT, $message . "\n");
+    if ($this instanceof BrowserTestBase) {
+      $this->htmlOutput($message);
+    }
+    else {
+      throw new \BadMethodCallException('This method is only supported by BrowserTestBase tests');
     }
   }
 
