Can we have two evn.rb files in cucumber framework for Watir-Webdriver and REST API project Testing

175 views Asked by At

Presently i have two individual projects for Rest API and Watir-webdriver with cucumber , so i planned to move them into one project , so is it possible to make it as one project

I would like to keep My Rest API framework [ Cucumber + Httparty + Json ] and Watir-webdriver framework [ Cucumber + Watir-webdriver ] in one project, Is it possible can anyone help me?

1

There are 1 answers

5
Pippo On BEST ANSWER

It's possible to have service/browser tests within the same project, actually, it's common given a lot can be reused between both ui and service test layers... I don't think it's possible to have 2 env.rb files and to be honest there is no reason why you would want to... but I get why you thought about it...

There are a LOT of ways you can manage your service/ui frameworks within a single repo and it's entirely up to you the path you follow... Below is one of many ways you can accomplish this:

Within both of your frameworks, you probably have unique setup in you env.rb... abstract those unique dependencies into a module in the same level as env.rb, for example:

service.rb
browser.rb

Within each module add the steps you require for your ui/service tests:

module ServiceHelper/BrowserHelper      
  def service_setup/browser_setup
  end
end

now in your env.rb file, based in some ENV variable config you call the setup for your browser or service test:

require 'service'
require 'browser'

include 'BrowserHelper'
include 'ServiceHelper'

if ENV['driver'] = 'service'
  service_setup
elsif ENV['driver'] = 'browser'
  browser_setup
else
  ...
end

In the end, you will probably find that your UI tests will reuse a lot of stuff from you service test suite, for example, data setup can be done via services to assist your UI tests... when you get to that conclusion, you will no longer need to have a clause and load one or the other... but the abstracting setup service/browser into modules, outside of env.rb is still a good practice, you then keep env.rb clean, and helps manage your different setup for different purposes...