The Beginners Guide for Getting Started with Automated Testing using R

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

slide 1:

The Beginners Guide for Getting Started with Automated Testing using RSpec Selenium Automated testing is extremely on the boom across the board nowadays and obviously Ruby has its own arrangements to make it work for RoR developers. One of these is RSpec a madly prevalent tool for mechanized testing. The fortunate thing about it is we can test almost every part of Ruby on Rails RoR Application easily. Rspec is easy to get it up and running expressive way to write test cases easy to use and also fast. Let’s start with assembling all components together to start off with: To begin it’s necessary to install Ruby. You can do it from here for Windows OS: http://www.rubyinstaller.org After you are done with installation let’s check if Ruby is installed properly along with version number.

slide 2:

 For this go to command prompt and type: ruby -v You will get the following result.  Next you need to install Rspec gem. Gem is Ruby library which can be used in one’s own code.  Go to command prompt and type the following : gem install rspec You will get the following output: Done installing documentation for diff-lcs rspec-support rspec-mocks rspec-expectations rspec-core rspec after 22 seconds 6 gems installed  To start with Selenium in Ruby you also need to install the gem selenium-webdriver which will act as a binder for Ruby from command line. Type the following command to install ‘selenium-webdriver’:

slide 3:

gem install selenium-webdriver  Now create directory i.e folder to store rspec scripts. Open your command prompt and change the directory path to the one where you would be saving your scripts. Example: If your director name is ‘sample_scripts’ on desktop: C:\Desktop\sample_scripts Let’s start with writing script in rspec: So for this open any editor. Here I have used sublime.  Write the following code in sublime editor and save it. Save it with name sample.rb  To run the script go to command prompt and type:

slide 4:

C:\Desktop\sample_scriptsrspec sample.rb You will get output as following after executing the script: Finished in 0.002 seconds files took 0.11101 seconds to load 1 example 0 failures Keywords in Rspec: As this is targetted to new coders you need to know some keywords which are meant to be used in your code.This helps in understanding the protocol to be followed while coding.  describe..... do Description of collection of related test cases  it......do Individual test cases  Before and After Optional test statements run before and after each or all test cases. So let’s hope you have understood the significance of using Rspec while automation testing. This reduces your time to test and increases efficiency of testing. The code quality is needless to mention becomes high. All these steps are for test-driven development TDD environment if you want to know how to use RSpec in Behaviour Driven Development BDD please referring to our previous blog about it. Aren’t we testers meant to have this as our focus So let’s start testing with RSpec and Selenium.

authorStream Live Help