Archive
Introduction to Cucumber
More than a testing tool, Cucumber is a collaboration tool.
It is designed to accommodate both the technical(developers, automation testers) and non-technical(stakeholders, product owners) members of the software development team.
Cucumber supports behavior-driven development(BDD). In BDD, users(business analysts, product owners) first write scenarios or acceptance tests that describes the behavior of the system from the customer’s perspective, for review and sign-off by the product owners before developers write their codes.
When you run your test, Cucumber reads through user-readable files called features, parse it to scenarios which contains set of steps that are then matched to a step definitions of Ruby code using a regular expression.
Feature files could be deceiving. It may look simple and plain in the outside. But complex in the inside, within step definition or the ruby files which controls the flow of actions and where all the magic happens.
In order for Cucumber to understand the feature files, it uses a basic syntax called Gherkin. Gherkin makes use of the following keywords for documentation and readability – Feature, Background, Scenario, Given, When, Then, And, But, *, Scenario Outline and Examples.
To dive more information about Cucumber, I would recommend you read The Cucumber Book which have valuable information you would need in learning this new technology.
In preparation to your Cucumber testing experience, will be needing to setup the following in your local machine.
1. Java installation – JRE will do, mine is Java(TM) SE Runtime Environment 1.6
2. Ruby installation – visit their Downloads page. I have Jruby 1.6.7.2 installed in my box.
Don’t forget to define Java and Ruby Path in your system’s environment variables as well.
3. RubyGems installation – use “gem install <name of gem>” command. Here are some of the basic, helpful gems:
- Cucumber
- Capybara
- Rspec
If you’re all setup, feel free to jump to the next post – Automated Testing with Cucumber + Capybara
Reference: The Cucumber Book by Matt Wynne and Aslak Hellesoy
Useful RubyMine Keyboard Shortcuts
Meet my new colleague, Jetbrains RubyMine “The Most Intelligent Ruby on Rail IDE” sounds big huh! Since he will be my new companion / buddy for the next months to come, I decided to know him better and build a good rapport.
Here are some of the keyboard shortcuts I find to be friendly and useful:
| Shortcut | Description |
| Ctrl+Alt+S | Go to Settings |
| Ctrl+N | Open a class |
| Ctrl+Shift+N | Open a file |
| Ctrl+B | Go to declaration |
| Ctrl+Space | Code completion |
| Ctrl+E | Show recent files |
| Ctrl+K | Commit changes |
| Ctrl+G | Go to line |
| Ctrl+T | Update project |
| Alt+Left/Right | Navigate through the editor tabs |
| Ctrl+Slash | Make a block comment |
| Ctrl+F | Find from current file |
| Ctrl+Shift+F | Find from current folder |
Error installing Nokogiri in Ubuntu 10.10
Following Nokogiri Installation for Ubuntu I run below #nokogiri requirement in my terminal:
sudo apt-get install libxslt-dev libxml2-devsudo gem install nokogiri
Running “sudo gem install nokogiri” displays the following error:
Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb extconf.rb:5:in `require': no such file to load -- mkmf (LoadError) from extconf.rb:5 Gem files will remain installed in /var/lib/gems/1.8/gems/nokogiri-1.4.3.1 for inspection. Results logged to /var/lib/gems/1.8/gems/nokogiri-1.4.3.1/ext/nokogiri/gem_make.out
Was able to resolve the issue by installing ruby1.8-dev and reinstalling the nokogiri gem:
sudo apt-get install ruby1.8-devsudo gem install nokogiriexist@exist:~$ sudo gem install nokogiri Building native extensions. This could take a while... Successfully installed nokogiri-1.4.4 1 gem installed Installing ri documentation for nokogiri-1.4.4...
Resolving “Couldn’t open app window; is the pop-up blocker enabled?” Selenium error in IE 10
Need to setup my Linux machine(master) to remotely access a Windows 8 machine(slave) with Internet Exporer 10 browser that will run my Selenium scripts.
master – machine where Selenium scripts, browser configurations are saved; one that will be sending requests to run the scripts
slave – machine where Selenium scripts will be run using a different platform (OS and browser); one that will accept the request to run the scripts
To do this, I configure the browser file from the master machine:
# for Internet Explorer our $sel = Test::WWW::Selenium->new( host => "Windows Machine IP", port => 4445, browser => "*iexplore", browser_url => "application URL" );
From the slave machine, I needed to install the following:
- Java SE Runtime Environment 1.7
- download latest Selenium Server from SeleniumHQ
To prepare the slave machine to accept the request, launch selenium server from the terminal using the same port set in the master machine:
java -jar selenium-server-standalone-2.23.1 -port 4445
To send request from the master machine, you may use “spec”, “rake” command depending on how you organized your test files. However after executing the command to run the scripts from the master machine, an error was encountered in the slave machine - “Couldn’t open app window; is the pop-up blocker enabled?”
# for Internet Explorer our $sel = Test::WWW::Selenium->new( host => "Windows Machine IP", port => 4445, browser => "*iexploreproxy", browser_url => "application URL" );
What are You Doing?
An investor once visited an IT company and was accompanied to the QA/Testing department. He approached the QA Analysts and tried to do some small talk.
Visitor: What are you guys doing?
Employee #1: Well, I’m executing these bunch of test scenarios repeatedly.
![]() |
| Image taken from http://www.zazzle.com |
Employee #2: Well, I’m trying to earn a living.
![]() |
| New Peso Bills |
Employee #3: Well, I make sure users will have a valuable experience with this cool stuff we are developing.
Although the three employees are doing the same task, only one of them sees the bigger picture of their work and truly understands the value of their job. #Perspective
What Drives You?
I’m consolidating great ideas I bump along the way that would somehow motivate us in our work place. I’ll be needing your help on this one, please feel free to add more on the list.
Inspired from Atlassian’s ”Fedex” Day. This is a time(24 hours) given to their developers to work on whatever they want as long as it is related to their products. This activity fosters creativity and fun.
2. Late Mo, Earning Ko
I heard this during one of my RX morning routines. This is company perks where employees tardiness deductions will be collected and distributed as reward to employees who have no tardiness. Cool huh!
Setup OpenVPN Client in Linux
I needed to install OpenVPN(open source virtual private network) in my Linux machine to be able to access our staging server. OpenVPN allows you to establish a secure point to point access to network resources and services.
OpenVPN can be used in two ways – Server and Client. OpenVPN server is the system that you wish to use as VPN end-point or the one you want to access. In my case what I needed to do is to install OpenVPN as client or the one making a service request.
1. Install OpenVPN using terminal:
sudo apt-get install openvpn
2. Create client configuration file in /etc/openvpn
sudo cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf /etc/openvpn
3. Setup client config file, server keys and certificates in /etc/openvpn folder (in my case our client sent these files generated from the server)
/etc/openvpn/client.conf
/etc/openvpn/keys/ca.crt
/etc/openvpn/keys/hostname.crt
/etc/openvpn/keys/hostname.key
/etc/openvpn/keys/ta.key
4. Edit client configuration file (client.conf) based on above directory
# example client config file
client
remote [server] 1194
dev tun
proto udp
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/hostname.crt
key /etc/openvpn/keys/hostname.key
ns-cert-type server
tls-auth /etc/openvpn/keys/ta.key 1
comp-lzo
keepalive 10 60
ping-timer-rem
persist-key
persist-tun
verb 3
5. Go to /etc/openvpn folder and start the OpenVPN
exist@exist:/etc/openvpn$ sudo openvpn client.conf
Mon Apr 23 13:44:43 2012 OpenVPN 2.1.0 x86_64-pc-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [MH] [PF_INET6] [eurephia] built on Jul 12 2010
Mon Apr 23 13:44:43 2012 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta16 and earlier used 5000 as the default port.
...
Mon Apr 23 13:44:50 2012 [server] Peer Connection Initiated with [AF_INET]xxx.xxx.xx.xxx:1194
Mon Apr 23 13:44:52 2012 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
...
Mon Apr 23 13:44:53 2012 TUN/TAP TX queue length set to 100
Mon Apr 23 13:44:53 2012 /sbin/ifconfig tun0 10.8.1.190 pointopoint 10.8.1.189 mtu 1500
Mon Apr 23 13:44:53 2012 /sbin/route add -net 192.168.3.0 netmask 255.255.255.0 gw 10.8.1.189
Mon Apr 23 13:44:53 2012 /sbin/route add -net 10.3.0.0 netmask 255.255.0.0 gw 10.8.1.189
Mon Apr 23 13:44:53 2012 /sbin/route add -net 10.8.1.1 netmask 255.255.255.255 gw 10.8.1.189
Mon Apr 23 13:44:53 2012 Initialization Sequence Completed
There you go! By this time, you should be able to access the application you want to test
However in our case we needed to setup the IP address of the server that we are trying to gain access in our hosts file. From the terminal, we type:
[user]@exist:~$ sudo su -
[sudo] password for [user]: [input password]
root@[user]:~# vi /etc/hosts
Then input the IP address and the corresponding name of the web server we are trying to access at the end of the line.







Recent Comments