Laravel 9迁移(单位测试)

发布于 2025-02-09 11:48:29 字数 557 浏览 1 评论 0原文

我正在使用Laravel 9应用程序,它没有迁移文件。 并且在编写测试用例时,我得到了服务器错误500,并且 pdoexception:sqlstate [hy000]:常规错误:1个这样的表:{table-name} in/vendor/laravel/framework/framework/src/illuminate/illuminate/database/database/connection.php:368

i创建了测试迁移文件并使用其路径运行,但不起作用,

class AppTest extends TestCase {      
      use DatabaseMigrations;
      public function setUp(): void {
         parent::setUp();
         Artisan::call('migrate', ['--path' => base_path('tests/migrations/')]);
     }
}

我如何在没有迁移文件的情况下测试该应用程序,还是还有另一种方法?

I'm working on a Laravel 9 app, it has no migration files.
And when writing test cases, I got server error 500 and
PDOException: SQLSTATE[HY000]: General error: 1 no such table: {table-name} in /vendor/laravel/framework/src/Illuminate/Database/Connection.php:368

I created test migration files and run them with its path but does not work

class AppTest extends TestCase {      
      use DatabaseMigrations;
      public function setUp(): void {
         parent::setUp();
         Artisan::call('migrate', ['--path' => base_path('tests/migrations/')]);
     }
}

How can I test the app without migration files, or is there another way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文