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|anidhya@gmail.com|
|password|123456|
And I press "submit"
Then I should see "Registration complete"
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
Now when I run the scenario , the user gets saved in the datab开发者_运维百科ase and the database cleaner fails. I dont see any error messages
- 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?
You can't run transactions with selenium because the test runs on two separate instances of the app AFAIK
精彩评论