diff --git a/tests/lib/SimpleSAML/Utils/ConfigTest.php b/tests/lib/SimpleSAML/Utils/ConfigTest.php
index 41052cf02ee815fb4dfb59050234b8a4919c355e..2e5777fcf3014bbbf9f5899b9f53c2ba4b6267ae 100644
--- a/tests/lib/SimpleSAML/Utils/ConfigTest.php
+++ b/tests/lib/SimpleSAML/Utils/ConfigTest.php
@@ -2,6 +2,7 @@
 
 namespace SimpleSAML\Test\Utils;
 
+use InvalidArgumentException;
 use PHPUnit\Framework\TestCase;
 use SimpleSAML\Utils\Config;
 
@@ -73,8 +74,8 @@ class ConfigTest extends TestCase
         $invalidDir = __DIR__.'/e9826ad19cbc4f5bf20c0913ffcd2ce6';
         putenv('SIMPLESAMLPHP_CONFIG_DIR='.$invalidDir);
 
-        $this->expectException(
-            \InvalidArgumentException::class,
+        $this->expectException(InvalidArgumentException::class);
+        $this->expectExceptionMessage(
             'Config directory specified by environment variable SIMPLESAMLPHP_CONFIG_DIR is not a directory.  '.
             'Given: "'.$invalidDir.'"'
         );