在测试数据库中保留大型数据集而不重新加载

发布于 2024-08-10 19:44:20 字数 101 浏览 2 评论 0原文

我使用黄瓜来运行集成测试。

我有一个非常大(30,000+ 条记录)的标准设置用于测试。

如何将其保留在 test.sqlite3 数据库中而不重新加载它?

I use cucumber to run integration tests.

I have a very large (30,000+ record) stardard setup for testing.

How can I leave that in the test.sqlite3 database without re-loading it ever?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

子栖 2024-08-17 19:44:20

测试运行完成后,Cucumber 不会清除数据库,除非您在 env.rb 文件中的 After 块中添加一些代码来执行此操作。

如果数据从未改变,则将其加载到数据库一次,并假设运行 Cucumber 时它就在那里。如果您在场景中更改数据库中的某些数据,请确保使用事务固定装置 当场景结束时,这些更改将被回滚。

Cucumber will not clean out the database once the test run completes unless you put some code to do it in an After block in your env.rb file to do this.

If the data never changes then load it into the db once and assume it is there when you run cucumber. If you change some data in the db in your scenarios then make sure that you use transactional fixtures and those changes will be rolled back when the scenario finishes.

不弃不离 2024-08-17 19:44:20

SQLite 数据库只是一个文件。难道您不能在开始测试之前复制所需的数据库文件(预先填充您想要的数据)吗?

The SQLite database is just a file. Couldn't you just copy over the desired database file (prepopulated with the data you want) prior to starting your tests?

惜醉颜 2024-08-17 19:44:20

好的,根据您所说的,您可以这样做吗:

Background: Create verses 
 Given the following verses exist:
 |number|text |
 |2999  |hello|
 |2998  |hello| 
 |2997  |hello| 
 |2996  |hello| 

Scenario: A user sees only verses in their reading plan
  Given I am signed in as the Reader "Rodreegez"
  And I have reading recomendations
  When I follow "Read"
  Then I should see the following verses: 
  |number|text |
  |2999  |hello| 
  |2998  |hello| 
  And I should not see the following verses: 
  |number|text | 
  |2997  |hello| 
  |2996  |hello| 

当然,这涉及到使用像 Factory Girl 这样的模型来创建诗句。这可能吗?

OK, based on what you said, can you do this:

Background: Create verses 
 Given the following verses exist:
 |number|text |
 |2999  |hello|
 |2998  |hello| 
 |2997  |hello| 
 |2996  |hello| 

Scenario: A user sees only verses in their reading plan
  Given I am signed in as the Reader "Rodreegez"
  And I have reading recomendations
  When I follow "Read"
  Then I should see the following verses: 
  |number|text |
  |2999  |hello| 
  |2998  |hello| 
  And I should not see the following verses: 
  |number|text | 
  |2997  |hello| 
  |2996  |hello| 

Of course, that rather involves creating the verses from a model using something like Factory Girl. Would that be possible?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文