I think the most challenging part of test automation is nowadays having Continuous Integration and one step more is having Continuous Deployment. These two terms have been a buzzwords around the software community, and everyone is talking about them but there are very few companies that can apply these. The reasons behind this can be listed as:
On the other hand, there are lots of open-source tools that you can just build and configure your own CI, and maybe next step goes to continuous deployment. In this post, I want to explain how you can set up CI on a Windows server. I will use the following tools/technology and language: Ruby, Gem (many Gems), Capybara, Cucumber, Windows Server, and Jenkins. You can follow the instruction, but possibly you can still have some different warnings or errors.
Install Jenkins
Download the appropriate version of Jenkins from the Jenkins home page
Install Ruby
Capybara uses only Ruby so you need to install it. Go to the Ruby Installer page and download it. Double-click on the installer and Install it to your system. I suggest you install a version newer than 2, from here.
Ruby Path
Set the Ruby path so that CMD can run ruby.exe, bundle.exe, and other Ruby-related executables. Installation is straightforward, just follow the instruction.
Clone Project
Your project should be located in Windows Server so that the Jenkins executor can run it locally. You may need to install git, I will use GitLab so I have already installed it. You install it from git scm. Installation is straightforward, just follow the instruction.
Install Bundler
Thanks to Ruby World, it is very easy to manage dependency.
gem install bundler
If you have a problem related to the recognition of Ruby or Gem, ensure that you have set the Ruby path correctly
Install Gems
Go to your automation project folder, there is a file called GemFiles which holds the necessary gems and versions if needed.
bundle install
if you have a DEVKit error:
C:\Users\Administrator\Documents\web-automation>bundle installFetching git://github.com/rspec/rspec-support.gitFetching git://github.com/rspec/rspec-mocks.gitFetching git://github.com/rspec/rspec-expectations.gitFetching git://github.com/rspec/rspec-core.gitFetching gem metadata from http://rubygems.org/.........Fetching version metadata from http://rubygems.org/...Fetching dependency metadata from http://rubygems.org/..Resolving dependencies....Installing rake 10.4.2Installing i18n 0.7.0 Gem::InstallError: The 'json' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKitfrom 'http://rubyinstaller.org/downloads' and follow the instructionsat 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'An error occurred while installing json (1.8.3), and Bundler cannot continue.Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
Download ruby DevKit from here and run the following commands in DevKit folder:
ruby dk.rb init
ruby dk.rb install
Still have a problem you can run this:
gem install json --platform=ruby --verbose
If you have a connection problem:
C:\Users\Administrator\Documents\web-automation>bundle install Fetching git://github.com/rspec/rspec-support.git fatal: unable to connect to github.com: github.com[0: 192.30.252.129]: errno=No error Retrying git clone "git://github.com/rspec/rspec-support.git" "C:/Ruby 200-x64/lib/ruby/gems/2.0.0/cache/bundler/git/rspec-support-4be3efb76b f1e3ed1a1313da599bae7c0aa16b28" --bare --no-hardlinks --quiet due to e rror (2/4): Bundler::Source::Git::GitCommandError Git error: command ` git clone "git://github.com/rspec/rspec-support.git" "C:/Ruby200-x64/l ib/ruby/gems/2.0.0/cache/bundler/git/rspec-support-4be3efb76bf1e3ed1a1 313da599bae7c0aa16b28" --bare --no-hardlinks --quiet` in directory C:/ Users/Administrator/Documents/web-automation has failed. fatal: unable to connect to github.com: github.com[0: 192.30.252.131]: errno=No error
Run the following command to set the direction to https:
git config --global url."https://github.com".insteadOf git://github.com
Add Jobs
I preferred to separate my test scenarios with tags so that if I have new stories related to predefined tags I will not need to change jobs, I will just a @tag when I write the code. Also adding a @regression tag for important cases to run more frequently. Therefore my execution command like as follows:cucumber features --tag @regression
You can add it to Jenkins by:
New Item > "Give Name" > Select "Freestyle Project" > click "OK" Build > Add Build Step > Execute Windows batch command > add the following cucumber C:\Users\Administrator\Documents\web-automation\features --tag @regression
Set the path again if you have a problem with finding ruby or other executives as follows: 'cucumber' is not recognized as an internal or external command, operable program, or batch file.
set PATH=%PATH%;C:\Ruby200-x64\bin; cucumber C:\Users\Administrator\Documents\web-automation\features --tag @regression
Check Jobs
8 scenarios (8 passed) 32 steps (32 passed) 0m37.854s Finished: SUCCESS