I am working on a legacy web application that has limited unit test and dependency on multiple applications. To reduce the manual testing effort, we had to write end-to-end UI tests with help of Cucumber, Capybara.
We had to chain few tests (generally BAD PRACTICE) as there was no way to create the seed data in every end-to-end test. We had to reuse the data from other scenarios. Rather than going into further details, here is an example where you can trigger another cucumber tag from a step:
child_process.feature
Feature: As a Cucumber user I want to run other feature from a step @success_child_process Scenario: run job Given no exception is raised @failure_child_process Scenario: run job Given exception is raised Scenario: Child Given I trigger @success_child_process job And no exception is raised And I trigger @failure_child_process job
child_process_steps.rb
Given /^no exception is raised$/ do # do nothing here end Given /^exception is raised$/ do raise 'Exception is raised' end Given /^I trigger (@.*) job$/ do |tag| CucumberChildProcess.run_tag tag end
cucumber_child_process.rb
require 'childprocess' module CucumberChildProcess def self.run_tag(tag) logger.info "Triggering the child process for tag '#{tag}'" process = ChildProcess.build(find_executable('bundle'), 'exec', 'cucumber', '-t', tag) process.io.inherit! process.start logger.info "********* CHILD PROCESS LOGS for tag '#{tag}' - START **********" process.wait logger.info "********* CHILD PROCESS LOGS for tag '#{tag}' - END **********" raise "Child process failed while running the tag '#{tag}'. Check the log for more information. Exit code: #{process.exit_code}" unless process.exit_code == 0 logger.info "Successfully executed the tag '#{tag}' as Child process" end def self.find_executable(cmd) ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| next if path.empty? path = File.join(path, cmd) ['.exe', '.bat'].each do |ext| return path + ext if File.exists?(path + ext) end end raise "Unable to find command '#{cmd}' in the PATH" end end
This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
ReplyDeletesoftware testing training in chennai
Great Article Artificial Intelligence Projects
DeleteProject Center in Chennai
JavaScript Training in Chennai
JavaScript Training in Chennai
Many thanks for a lovely post keep it up.
ReplyDeleteWeb Design Training
This site is very good to me. Because this site has much more sense post. So I am posting at the site. I would like to know more of the unknown.
ReplyDeleteTop posts and takes a lot of good to me and to all of the beautiful and the good.
laptop chiplevel training in hyderabad
Wow!! What a great blog!! I really liked your article and appreciate your work.
ReplyDeleteI have found this article while searching on internet and I would recommend this to everyone.
laptop chip level training in hyderabad
This article is well written and quite informative.
ReplyDeleteMore articles should be written and you have just found a follower.and more visit.
mainframe training in hyderabad
Wow cool site I have already withdrawn money from here. Actually my girlfriend advised me and I decided to risk the risk and you elegant uk casino I wish you more victories
ReplyDeleteVery good post.
ReplyDeleteAll the ways that you suggested for find a new post was very good.
Keep doing posting and thanks for sharing
matlab training in hyderabad
For Sexy and hot girls entertaining services
ReplyDeleteDubai Escorts
call girls in Dubai