标签: pestphp

使用 pest 在自定义测试套件中进行测试时,获取 InvalidArgumentException - laravel 中 fakerphp/faker 库的未知格式

我正在使用Pest库在 laravel 中编写测试。我my-laravel-application/tests/Integration在 laravel 中创建了目录并在中定义了一个新的测试套件phpunit.xml

<testsuite name="Integration">
   <directory suffix=".test.php">./tests/Integration</directory>
</testsuite>
Run Code Online (Sandbox Code Playgroud)

这样 Laravel 就会承认 Integration 目录中的测试文件,并且我可以在具有正确名称的单独目录(Integration 目录)中编写集成测试,并且我将测试文件放入该目录中my-laravel-application/tests/Integration,在运行时出现以下错误php artisan test

InvalidArgumentException - Unknown format "name"
vendor/fakerphp/faker/src/Faker/Generator.php:657
Run Code Online (Sandbox Code Playgroud)

这表明$this->faker->name()我的代码行UserFactory(我在测试中使用 UserFactory 类)有问题,它说 $this->faker 上不存在 name() 方法。但在将它们移动到目录之前,我的测试曾经运行良好my-laravel-application/tests/Integration。真正的问题是什么?我该如何解决这个问题?

php phpunit laravel pestphp

1
推荐指数
1
解决办法
1455
查看次数

标签 统计

laravel ×1

pestphp ×1

php ×1

phpunit ×1