Now lets start to create scenarios and do testing using cucumber
1)Lets create our first scenario as follows and save it in the product/features folder as named
list_of_product.feature
Scenario: Products List
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"
2)Now run the cucumber features and see the out put as
3)You get 1 scenario (1 undefined)
6 steps (5 skipped, 1 undefined)
that means your 1st step is not defined. That means the cucumber do not know how to deal with the step
GivenI have products titled Java, description Platform Independent, Image url java.jpg, Price 20
To deal with this that should be in the webrat_step.rb file in the features/step_definitions folder. If not we have to create them for the use of cucumber and you can see the cucumber suggest you some definitions as
Given /^I have products titled Java, description Platform Independent, Image url java\.jpg, Price 20$/ do
pending
end
4)Now lets create the definition file. Create a file named product_step.rb file in the features/step_definitions folder and paste the following code there and save it.
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
In this step it says to store the data in the table called Product.
5)Now lets run again cucumber features and see the result. You can see following error.
This says there is no such a constant like Product. This means still we do not create our Product Table lets create our product table. Type on the terminal as follows.
ruby script/generate scaffold product title:string description:text image_url:string price:decimal
rake db:migrate
6)Now lets run again cucumber features
That says that product_test.products table. That because these scenarios working with the tables in the test database. So lets fix it. Run following code.
rake db:test:clone
Now lets run again cucumber features.
7)Its hows the following error and add it to the file path.rb in features/support
this should come after case statement
when /the list of Products/
products_path
the reason for this is (
We have our first passing step! The second step is now failing, though. This is because Cucumber doesn’t know how to translate “the list of articles” into a path in our application.
One of the files installed by Cucumber is called paths.rb, which lives in the /features/support directory. In this file we can define custom paths that map the English definitions in Cucumber files to paths in our Rails application. To add a mapping we just add a new when condition to the case statement in the path_to method. (There’s a comment in the file to show us where to add it.)
)
8)Now run again cucumber features 
9)You get all the scenarios are passed.
10)Now our first scenario is passed lets try another scenario in the next post. Try this scenario and check you can understand it. Copy and paste to the same feature file
Scenario: Products List
Given I have products titled Java, description Platform Independent, Image url java.jpg, Price 20
And I have products titled Ruby on Rails, description Rich internet Application, Image url ror.gif, Price 25
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"
Then I should see "Ruby on Rails"
And I should see "Rich internet Application"
And I should see "ror.gif"
And I should see "25"
Cucumber and Ruby on Rails (Part 3) My learning materials
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 3:29 PM 2 comments
Ruby cucumber Part3
Hi all,
I am very sorry for the delay of my 3rd post because these days are i am very busy. i hope to do it as soon as possible. Most probably today afternoon i can do it.
Cheers,
jeewantha.
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 12:11 PM 0 comments
Cucumber and Ruby on Rails (Part 2) My learning materials
Create a project and do testing using cucumber.
Project name “product”
Requirement
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
He should be able to add new products.
He should be able to show the products.
He should be able to edit products.
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.
When Edit product the validation also should be done.
He should be able to navigate any places by clicking links.
He should be able to delete products.
Product table contents
Title = String
Description = String
Image Url = String
Price = Decimal
Lets start developing the project.
Install cucumber
sudo gem1.8 install cucumber
The plugins’ dependencies must be installed separately:
gem install term-ansicolor treetop diff-lcs nokogiri
Lets start developing our project
Open a terminal then type
rails -d mysql product
cd product
rake db:create:all
rake db:migrate
Now lets try to create cucumber
ruby script/generate cucumber
Then run
Cucumber features
Now you are ready to work with cucumber
lets see that in next post.
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 10:15 AM 2 comments
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.
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 4:39 PM 0 comments
Working with Ruby on Rails Cucumber From the Beginning(Part I)
Create a project and do testing using cucumber.
Project name “product”
Requirement
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
He should be able to add new products.
He should be able to show the products.
He should be able to edit products.
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.
When Edit product the validation also should be done.
He should be able to navigate any places by clicking links.
He should be able to delete products.
Product table contents
Title = String
Description = String
Image Url = String
Price = Decimal
Lets start developing the project.
Install cucumber
sudo gem1.8 install cucumber
The plugins’ dependencies must be installed separately:
gem install term-ansicolor treetop diff-lcs nokogiri
Lets start developing our project
Open a terminal then type
rails -d mysql product
cd product
rake db:create:all
rake db:migrate
Now lets try to create cucumber
ruby script/generate cucumber
Then run
Rake Features Or Cucumber features
Then u can see as follows
Now you are ready to work with cucumber
lets see that in next post.
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 5:29 PM 0 comments
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.
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 11:32 AM 0 comments
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.
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 2:47 PM 1 comments
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
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 9:19 PM 0 comments
WELCOME to Jeewantha's Blog
Welcome All for my blog and this blog is for Software Quality Assurance Stuffs
Posted by ජීවන්ත තාරක (Jeewantha Tharaka Kodikara) at 11:54 AM 0 comments


