Tool for creating counterstrings

Reading Time: 1 minute


In this post I am presenting web tool that creates counterstrings.

Counterstrings are created by James Bach. They are self describing test data and because of that property, they are example of self verifying test data.

Self verifying test data is one of concepts that you can learn in BBST Foundations. As I have been co instructor in AST BBST Foundations course, I have first hand experience that students have trouble grasping the concept of self verifying test data.

How do we know that some test data is self verifying data? If JUST BY OBSERVING THAT DATA, with NO any help with other test data, we know that feature is working or not. Counterstrings could be used in order to determine the length of input field.

For homework, write self verifying test data for math square function:


Here is Ruby code that calculates counterstrings:

Application is created with Ruby on Rails framework. I had to resolve following design problems (and stuff that I learned):

  • write counterstrings algorithm in Ruby
  • check that algorithm using rspec
  • what is practical maximal allowed counterstring length?
  • how to pass variable between different Rails routes
  • how to wrap long string in html
  • copy paste string to clipboard
Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

How to send shift and special characters in Selenium Webdriver with Ruby

Reading Time: 1 minute


In order to automate one browser scenario, I needed to send ampersand character. It seems that this is not an easy action in selenium webdriver. So, instead testing the web application, I spent some time in order to find out a hack how to send ampersand key to browser in programmatic way.

My first reaction was: Is this for real, selenium-driver ate ampersand character!? Google as helpful, I found following blog post how to resolve this issue. Solution is in Python, so I rewrote it in Ruby.


Instead of trying to find the solution how to automatically send ampersand in ruby to browser, instead I could do that “manually” and continue the real testing activity. So, my dear testers, when you hear developers claiming that they test their application, prove them wrong. They just try to find solutions how to use automation framework, and that has nothing with sapient activity, software testing!

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Simulating time in Ruby on Rails

Reading Time: 1 minute


In this post I will provide an example why Ruby on Rails is great framework that has testability in its core design.

Time is a measure in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. Time is often referred to as the fourth dimension, along with the three spatial dimensions [source: Wikipedia].

When tester needs to test time related features, he needs to become time traveler. Ruby on Rails has very interesting time machine. It consists of Rails console and panel that helps you to set in which direction you are traveling.

Using that time machine, you can easily simulate time lapses. For example, using UI interface, you created one business object. Features says that email about this object should be sent after one week. What is easier, setting the machine system time, or simulate that time lapse in Ruby console? Here is gist:

Instead of setting system time one week in the future, we updated object time to be one week in the past. Notice plain english for setting created_at parameter! Refer to [direction you are traveling] link for more time calculation idioms.

Congratulations on your first time travel in Ruby on Rails framework!

But I am not using Ruby on Rails framework! Do not worry, by knowing Rails time machine, consult your developer does his framework has something similar.



rails console

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Runing Firefox on AMI Linux instance using Jenkins

Reading Time: 3 minutes


In this post I will give step by step instructions for setting up Jenkins on AMI Linux host. Jenkins will run selenium webdriver tests on Firefox in headless mode.

Install Jenkins

1. `sudo wget -O /etc/yum.repos.d/jenkins.repo`
2. `sudo rpm –import`
3. `sudo yum install jenkins`
4. `sudo yum remove java`
5. check that `java -version` is something like OpenJDK 64-Bit Server VM
6. check that jenkins runs on 8081
`sudo cat /etc/sysconfig/jenkins | grep JENKINS_PORT`
7. `sudo service jenkins start`
8. `curl http://localhost:8081` should return jenkins home html page

Control Jenkins

`sudo service jenkins start/stop/restart`
log file `/var/log/jenkins/jenkins.log`
config file `/etc/sysconfig/jenkins`


  1. `sudo yum install git`
  2. `sudo -u jenkins /bin/bash –login`
  3. `curl -sSL | bash`
  4. `rvm install ruby_from_dot_ruby-version_file`


Install it as jenkins user:
`sudo -u jenkins bash`

Installation instructions.


`sudo yum install xorg-x11-server-Xvfb`

Check xvfb

first terminal:
`Xvfb :1 -screen 0 1280x768x24`

another terminal:
`export DISPLAY=:1`

It is known that after sudo yum update, xvfb will fail with following error.

`Xvfb: symbol lookup error: Xvfb: undefined symbol: pixman_glyph_cache_create`

And console with firefox will report:

`Xvfb: symbol lookup error: Xvfb: undefined symbol: pixman_glyph_cache_create`

In order to resolve this issue, you need to run:

`rm /usr/local/lib/`


Jenkins security

Follow instructions from paragraph Password protect Jenkins.

## Jenkins plugins

Paragraph Install Jenkins plugins.
Install rvm plugin.


Configure Jenkins to run cucumber tests

0. become jenkins user: `sudo -u jenkins /bin/bash –login`
in `/var/lib/jenkins` folder, create ssh key.
copy `/var/lib/jenkins/.ssh/` to github deploy keys.
1. login to jenkins web console (before create your account)
2. create new job
3. project name: unique_project_name_by_your_decision
4. check discard old builds, strategy log rotation, max # of builds to keep 10.
5. source code management is git, your repository url is your git repository *.git
6. credentials: none
7. branches to build: */master (or whatever you like)
8. Build environment, check run the build in a RVM-managed environment
9. Implementation: e.g. ruby-2.1.2@gemsetname
10. ssh agent check
11. select credentials jenkins
12. add credential jenkins if not present
13. scope: global, type: ssh private key, username: jenkins, private key from a file on jenkins master: /var/lib/jenkins/.ssh/id_rsa
14. add build step: execute shell, `cd $WORKSPACE`
15. add build step: execute shell, `bundle install`
16. add build step: execute shell, `cucumber features -f html – o reports/report_$BUILD_TAG.html`
17. save
18. `ssh to AMI linux instance
19. `sudo -u jenkins /bin/bash –login`
20. Only first time create your test configuration files that are not present in git repository. E.g. application.yml file (repository has content instructions ) in
`vi /var/lib/jenkins/jobs/unique_project_name_by_your_decision/workspace/config/application.yml`
21. You can check cucumber execution report in workspace/reports

**Tip and tricks**

Once you have one jenkins job, in order to create another one, just use feature `copy existing item` in New Item feature. Edit configuration as appropriate and hit OK. Run the job that will fail. After that, do action from step 21. and task is ready.

Jenkins rest api

1. first obtain csrf crumb
`curl http://jenkins_username:jenkins_password@`
you will get:
2. start jenkins job:
`curl http://jenkins_username:jenkins_password@ -H “.crumb:f4828a00ccfe682b59b3977f8fdc8134” –data “”`
jenkins_username, password and api token are you jenkins credentials.

Runing firefox in headless mode

`sudo Xvfb :10 -ac` – start Xvfb server.
`export DISPLAY=:10`

This should be part of Jenkins job configuration.


Ant that it is, your AMI linux is ready to run your cucumber selenium webdriver tests in headless mode.

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather