DATA ZOO

Thoughts on Software

Testing Web Apps With Selenium Page Objects

Why?

During the process of developing a web application, the structure of web pages often changes. If you have several Selenium tests that test different functionalities of one page, you don’t want to change all your tests if the page changes only its layout.

Let say you have twelve tests which access the page. Now you need to change the page to display an additional table row. Your selenium test would probably fail, because the expected data is now at a different place on the page.

The solution: Use abstractions!

Your tests should not access the page structure itself but use abstractions of the page. This means you would only need to adapt the abstraction of the page and the twelve tests wouldn’t need any modification.

Page objects should be the only thing that have a deep knowledge of the structure of the HTML of a page. Think of the methods on a Page Object as offering the “services” that a page offers rather than exposing the HTML strucure of the web page.

From the Page objects page:
As an example, think of the inbox of any web-based email system. Amongst the services that it offers are typically the ability to compose a new email, to choose to read a single email, and to list the subject lines of the emails in the inbox. How these are implemented shouldn’t matter to the test.

If your programming in Ruby you might want to use page-object . page-object is a simple ruby gem that assists in creating flexible page objects for testing browser based applications.

Mocks in Java

Mock objects are simulated objects that mimic the behavior of real objects in controlled ways.

Mockito is my favourite mocking framework for Java for writing mock objects usable by unit tests.

Here is an example:

But sometimes you need to mock something which Mockito can’t handle.

PowerMock is an extension to Mocking frameworks like Mockito. It extends these frameworks to mock things like static methods or constructors.

The PowerMock website has a good page explaining how to use PowerMock with Mockito .

People Who Can Code

“People who can code in the world of technology companies are a dime a dozen and get no respect. People who can code in biology, medicine, government, sociology, physics, history, and mathematics are respected and can do amazing things to advance those disciplines.”

Zed Shaw

Gegenwart

“Nur wenige leben in der Gegenwart; die meisten bereiten sich darauf vor, demnächst zu leben.” Jonathan Swift

Why Does Test Driven Development Matter?

An excellent Talk by Robert Martin called “What Killed Smalltalk Could Kill Ruby, Too” that shows why test driven development (TDD) as a concept is so important, not only for Ruby projects but for every software project.

The TDD relevant part starts at 23m 56s .

JRuby as an Exceptions-as-flow-control Detector

Chris Heald shows in his article ‘JRuby Performance: Exceptions are not flow control’ how the anti-pattern of using ‘exceptions as flow control’ has an serious effect on the performance.

Thanks to headius logging the exceptions is as easy as:

jruby -Xlog.exceptions=true -Xlog.backtraces=true -Xlog.callers=true -S trinidad 2>&1 | grep "Backtrace generated" -A4

BTW: trinidad is used to run rails and rackup applications in an embedded Apache Tomcat

UML Notation Auf Einer Seite

Eine der besten und prägnantesten Übersichten für die UML (Unified Modelling Language) habe ich bei Wikipedia gefunden.

Leider wurde es dort nur im PNG bzw. SVG Format veröffentlicht. Daher habe ich es vom Vektorformat direkt nach PDF konvertiert, das sich am besten von allen Formaten ausdrucken läßt.

Herunterzuladen hier:

UML-Diagramme.pdf