Protractor E2E 测试种子数据库 [英] Protractor E2E Test Seed Database

查看:20
本文介绍了Protractor E2E 测试种子数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有找到这样做的好方法,所以希望有人有一些想法.在运行 E2E Protractor 测试之前,有什么方法可以使用测试数据为数据库播种?

I haven't found a good way of doing this so hoping someone has some ideas. Is there any way to seed the database with test data before running a E2E Protractor test?

人们会这样做还是只是模拟后端?对我来说模拟后端不是一种选择,因此希望了解如何为数据库播种的想法.有一些使用节点的解决方案,但没有定论.

Do people do this or do they just mock out the back end? Mocking out the back end for me is not an option so would appreciate ideas on how to seed the database. There are a few solutions out there using node but nothing conclusive.

对于我的案例,E2E 测试的重点是进入数据库级别

The whole point of E2E testing for my case would be to go to the DB level

谢谢

推荐答案

在NodeJs环境下,你可以从量角器直接连接到数据库,但我不会走那条路.您必须更新您的 SQL 设置脚本以及对后端的更改.

Being in a NodeJs environment, you can connect to the database directly from Protractor, but I wouldn't go down that route. You'll have to update your SQL-setup-script along with your changes to your back-end.

还有其他方法:

  1. 使用您现有的 REST 外观来填充您的数据库 - 注册用户、与其他用户连接等.如果您使用唯一数据设置每个测试,您将能够以这种方式同时运行它们.
  2. 向您的测试环境公开一个特殊的 REST 点,该点会在测试之间为您完成所有清理/设置.

您可以直接触发 REST 调用 从量角器环境使用您的浏览器.

You can fire REST calls directly from the Protractor environment or use your browser for that.

这篇关于Protractor E2E 测试种子数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆