本文介绍了数据库清理程序与黄瓜轨道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为注册表单写一个场景。
I am writing a scenario for signup form.
@abc
@selenium
Scenario:Non registered user signs up
Given I am on the sign-up page
When I fill in the following:
|first_name|Anidhya|
|last_name|Ahuja|
|email|[email protected]|
|password|123456|
And I press "submit"
Then I should see "Registration complete"
我想在这种情况后使用数据库清理器回滚测试数据库,以便我可以一次又一次地使用这个场景。
对于env.rb文件我写道:
I want to use database cleaner to roll back the test database after this scenario so that I can use this scenario again and again.
For that inside my env.rb file I wrote:
begin
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :transaction
Cucumber::Rails::World.use_transactional_fixtures = true
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Before('@abc') do
DatabaseCleaner.start
end
After('@abc') do
DatabaseCleaner.clean
end
现在当我运行场景时,用户被保存在数据库中,并且数据库清理器失败。我没有看到任何错误讯息
- 请澄清如何使用数据库清理器只有一个场景。
- 此外,您还可以提供使用截断和事务之间的重要区别。我认为截断会清除整个数据库,但是 >
- Could you please clarify how to use database cleaner for only one scenario.I only want to use cleaner for this scenario.
- Also could you please also provide the vital difference between using truncation and transaction.I think truncation clears the whole database but I dont want that.
- Is there a better method of doing signup testing than this?
推荐答案
您无法使用selenium运行事务,因为测试运行在应用程序AFAIK的两个单独实例上
You can't run transactions with selenium because the test runs on two separate instances of the app AFAIK
这篇关于数据库清理程序与黄瓜轨道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!