如何防止在Django中的每个测试案例之后刷新测试数据库中的数据

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

我目前正在编写我的第一个Django应用程序,并编写用于测试UI的硒测试用例。我正在使用Django测试用例类来测试应用程序。这是用于运行测试用例的配置:

"configurations": [
        {
            "name": "test",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}\\manage.py",
            "args": [
                "test",
                "review.tests.test_selenium.ReviewTests.test_app",
                "--keepdb"
            ],
            "django": true
        }
]

此配置使用现有的测试数据库,每次运行新的测试用例时,我都必须在表中添加数据。运行测试用例后,有什么方法可以保留数据?

python django django-testing
1个回答
1
投票

对于测试,数据不单独存储。为此,有setUp功能。或使用--keepdb标志。

© www.soinside.com 2019 - 2024. All rights reserved.