Links to My Posts

Labels

Blogumulus by Roy Tanck and Amanda Fazani
free counters

How many in online

Cucumber and Ruby on Rails (Part 2) My learning materials

Create a project and do testing using cucumber.

Project name “product”

Requirement

  1. The user can see the available products.

When the user come to the page he should be able to see all the available products with description like

Title: Ruby on Rails

Description: Model, view, controller architecture

Image Url: ror.jpg

Price: 21

  1. He should be able to add new products.

  2. He should be able to show the products.

  3. He should be able to edit products.

  4. He should be able to validate products details when adding new products.

Error massages should be display when there is a wrong with adding data like

Price should be number

Title cant be blank etc.

  1. When Edit product the validation also should be done.

  2. He should be able to navigate any places by clicking links.

  3. He should be able to delete products.

Product table contents

Title = String

Description = String

Image Url = String

Price = Decimal


Lets start developing the project.

  1. Install cucumber

sudo gem1.8 install cucumber

  1. The plugins’ dependencies must be installed separately:

gem install term-ansicolor treetop diff-lcs nokogiri

  1. Lets start developing our project

Open a terminal then type

rails -d mysql product

cd product

rake db:create:all

rake db:migrate

  1. Now lets try to create cucumber

ruby script/generate cucumber

  1. Then run

Cucumber features

  1. Then u can see as follows




  1. Now you are ready to work with cucumber

  2. lets see that in next post.



Cucumber and Ruby on Rails (Part 1)



I write this post to exchange my experienced with you about Cucumber and ruby and rails.

What is cucumber?
Actually when i heard this word i get a funny and i get a picture as follows.

After that i searched web and i try to find tutorials for learning this myself. when i was finding about cucumber i got idea about as follows.


After that i started finding and do various type of tutorials and try to get basics of cucumber. But it was very difficult to me learn this because there are not much tutorials for that i found 2 tutorials and by refering them i got basic idea and i think to share my knowledge with others so that is why this kind of blog post is come out. I think this will for the begginers to get an idea.

Now lets see what is the cucumber in ruby on rais and in other post how to start to test a project using cucumber.

Cucumber (Behavioral Driven Development ) is used for testing the behavior of a code. the programmers says that cucumber is used for accepting testing. Any way this is used for behaviral testing.

Reads plain texts….
Texts are written as scenarios
Scenarios interact with the code
Check the Codes are correct

Cucumber lets software development teams describe how software should behave in plain text. The text is written in a business-readable domain-specific language and serves as documentation, automated tests and development-aid - all rolled into one format.

Lets see the simple senario and discuss about it.

Scenario: Listing & showing products
Given I have products titled Java, description Platform Independent, Image url java.jpg, Price 20
When I go to the list of Products
Then I should see "Java"
And I should see "Platform Independent"
And I should see "java.jpg"
And I should see "20"

As u can see the the senario is describe in palain text. here the Given, When, Then and And are the key words which is used by the cucumber. how the cucumber work with this type of plain text for that it uses the regular expressions. See the folowing regular expression (Don't wory that much about that we'll see them leter in detail)

Given /^I have products titled (.+), description (.+), Image url (.+), Price (.+)$/ do
|title,description,image_url,price|
Product.create!(:title => title, :description => description, :image_url => image_url, :price => price)
end

This describes the first step of the above senario. we do not much trouble with regular expressions. Becuse when we generate cucumber we get predefine regular expressions in webrat_steps.rb file.

Now I think u have basic idea about cucumber. In next posts lets see step by step to create a project and testing project using cucumber.

Working with Ruby on Rails Cucumber From the Beginning(Part I)


Create a project and do testing using cucumber.

Project name “product”


Requirement

  1. The user can see the available products.

When the user come to the page he should be able to see all the available products with description like

Title: Ruby on Rails

Description: Model, view, controller architecture

Image Url: ror.jpg

Price: 21

  1. He should be able to add new products.

  2. He should be able to show the products.

  3. He should be able to edit products.

  4. He should be able to validate products details when adding new products.

Error massages should be display when there is a wrong with adding data like

Price should be number

Title cant be blank etc.


  1. When Edit product the validation also should be done.

  2. He should be able to navigate any places by clicking links.

  3. He should be able to delete products.

Product table contents

Title = String

Description = String

Image Url = String

Price = Decimal


Lets start developing the project.


  1. Install cucumber

sudo gem1.8 install cucumber


  1. The plugins’ dependencies must be installed separately:

gem install term-ansicolor treetop diff-lcs nokogiri



  1. Lets start developing our project

Open a terminal then type

rails -d mysql product

cd product

rake db:create:all

rake db:migrate




  1. Now lets try to create cucumber

ruby script/generate cucumber


  1. Then run

Rake Features Or Cucumber features


  1. Then u can see as follows



  1. Now you are ready to work with cucumber

  2. lets see that in next post.






First month of My Internship at Ridgecrest Asia (pvt) Ltd.

What I did the first month
1) Learned Ruby on Rails...........
2) Worked with Linux Platform (UBUNTU)
3) Learned about Software Quality Assurance
4) Developed a shopping cart using ruby on rails

What I learned In this Month
1) Basics of software quality assurance
i. Software testing types
ii. test automation and tools
ii. Experienced with two automation tools.
2) Ruby in Rails programming language
3) Basic Linux commands.

Test Automation Tool

There are a lot of test automation tool in software industry. the iMacro and selenium IDE re two of them. Both can be installed as a firefox add-on. lets see how can it be done. in the next post.

Test Automation

Test automation is the use of software to control the execution of tests, the comparison of actual outcomes to predicted outcomes, the setting up of test preconditions, and other test control and test reporting functions. Commonly, test automation involves automating a manual process already in place that uses a formalized testing process.

Although manual tests may find many defects in a software application, it is a laborious and time consuming process. In addition it may not be effective in finding certain classes of defects. Test automation is a process of writing a computer program to do testing that would otherwise need to be done manually. Once tests has been automated, they can be run quickly. This is often the most cost effective method for software products that have a long maintenance life, because even minor patches over the lifetime of the application can cause features to break which were working at an earlier point in time.

There are two general approaches to test automation:

  • Code-driven testing. The public interfaceto classes, modules, or libraries are tested with a variety of input arguments to validate that the results that are returned are correct.
  • Graphical User Interface testing. A testing framework generates user interface events such as keystrokes and mouse clicks, and observes the changes that result in the user interface, to validate that the observable behavior of the program is correct.

Test automation tools can be expensive, and it is usually employed in combination with manual testing. It can be made cost-effective in the longer term, especially when used repeatedly in regression testing.

What to automate, when to automate, or even whether one really needs automation are crucial decisions which the testing (or development) team has to take. Selecting the correct features of the product for automation largely decides the success of the automation. Automating unstable features or features that are undergoing changes should be avoided.

reference:- http://en.wikipedia.org/wiki/Test_automation

WELCOME to Jeewantha's Blog

Welcome All for my blog and this blog is for Software Quality Assurance Stuffs