结合django测试和testcafe?

问题描述 投票:0回答:1

我正在使用 testcafe 进行前端测试 https://testcafe.io/documentation/402631/guides/overview/why-testcafe 和后端 django https://docs.djangoproject.com/en/5.0/topics/testing/overview/#running-tests

如果我启动两个单独的 shell:

 python ./manage.py test #backend

 testcafe chromium ./tests/testcafe.js  #frontend

后端测试运行速度比前端快。 我想使用 django 测试功能为每次执行创建一个空数据库。 django 测试后端,有没有办法将它们组合起来?

django testing frontend backend
1个回答
0
投票

Django 的

test
命令 用于运行单元测试而不是集成测试。

如果您想轻松地使用空数据库设置测试服务器,Django 有一个

testserver
命令 用于此目的。此命令还允许您将一些数据加载到使用 fixtures 创建的测试数据库中。因此,您可以通过运行来启动测试服务器:

python ./manage.py testserver
© www.soinside.com 2019 - 2024. All rights reserved.