量角器E2E测试种子数据库
我还没有找到一个很好的方法来完成这项工作,所以希望有人有一些想法.在运行E2E量角器测试之前,是否可以通过测试数据为数据库播种?
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.
对于我的案例而言,端到端测试的全部要点是进入数据库级别
The whole point of E2E testing for my case would be to go to the DB level
谢谢
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.
还有其他方法:
- 使用现有的REST门面来填充数据库-注册用户,与其他用户连接等.如果使用唯一数据设置每个测试,则可以同时运行它们.
- 为您的测试环境提供一个特殊的REST点,可以在两次测试之间为您进行所有清除/设置.
您可以直接触发REST调用在量角器环境中或使用浏览器来实现.