如何使用Symfony2和Doctrine在Behat功能测试中回滚提交? [英] How to rollback commits in Behat functional tests with Symfony2 and Doctrine?

查看:164
本文介绍了如何使用Symfony2和Doctrine在Behat功能测试中回滚提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Symfony2应用程序中使用Behat和Mink编写功能测试。



我利用数据库中已经存在的数据进行测试,而不是添加灯具(很多需要)。



因此,我不能仅在测试环境中使用SQLite数据库,因为数据将不可用。 >

我的测试工作正常,但在运行测试时数据保留在数据库中。



我如何自动清理在运行情境后,Doctrine持续存在的数据?



我不能使用事务作为功能测试涉及页面重定向(例如,表单已填写并发布到其他Symfony2动作)。

解决方案

如果您持续存在数据,我无法自动恢复所有内容。
我只是做一个数据库的副本,对它进行测试,然后放下。


I'm writing functional tests with Behat and Mink in a Symfony2 application.

I make use of the data that's already in the database to make the tests instead of adding fixtures (a lot would be needed).

Therefore, I can't use a SQLite database only for the test environment as data would not be available.

My tests work fine, but data is persisted in the database when tests are run.

How can I automatically clean up data that's been persisted with Doctrine after a scenario is run?

I can't use a transaction as functional tests involve page redirections (e.g. the form is filled and posted to an other Symfony2 action).

解决方案

if you're persisting data I see no way to automatically revert everything. I would simply make a copy of the database, do the tests on it and drop it afterwards.

这篇关于如何使用Symfony2和Doctrine在Behat功能测试中回滚提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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