0

I am trying to run the Magento web api tests by running the following command:

vendor/bin/phpunit --config ./dev/tests/api-functional/phpunit_rest.xml

But it gives this error:

PHP Fatal error:  Uncaught PHPUnit\Framework\Exception: Could not read "".

/var/www/osp.example.com/magento-headless/Magento2/dev/tests/api-functional/testsuite/Magento/WebApiTest.php:39
/var/www/osp.example.com/magento-headless/Magento2/vendor/phpunit/phpunit/phpunit:61

  thrown in /var/www/osp.example.com/magento-headless/Magento2/vendor/phpunit/phpunit/src/Util/Xml.php on line 135

After a lot of debugging, I see that WebpApiTest.php runs the function getConfigurationFile which gives back an empty string. This is the code of that function:

    /**
     * Returns config file name from command line params.
     *
     * @return string
     */
    private static function getConfigurationFile(): string
    {
        $params = getopt('c:', ['configuration:']);

        $longConfig = $params['configuration'] ?? '';
        $shortConfig = $params['c'] ?? '';

        return $shortConfig ? $shortConfig : $longConfig;
    }

I don't really get what its doing and which information it is supposed to return. Can anyone check what kinda information it is supposed to return? Maybe then I can fix it and run the webapi tests of Magento 2.

1
  • Did you fix this issue? Commented Aug 5, 2021 at 17:09

2 Answers 2

0

Does the file ./dev/tests/api-functional/phpunit_rest.xml exist?

Magento includes ".dist" versions of configuration files for certain tools. The first step to using them is to make a copy without the ".dist" extension (thus preserving the original as a backup/reference).

3
0

It seems like PHPUnit tries to find a file named after the name-attribute of the testsuite-tag

  1. if it either cannot find any tests (wrong naming or wrong directory)
  2. here is a fatal error occuring in a test-script; which occures so early that PHPUnit cannot identify the content of that file as a test - as no class could be loaded up until that point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.