Jul
15
2010

Application Acceptance Testing

Yesterday evening I found a set of Google blog posts talking about web application acceptance testing which reflect Google experience through “Several years of experience across multiple project teams”.

This reflect lot of points I brought into our discussions either at Innoveo or Jobping; best practices, screen/page object, dev. language, recording/coding, BDD..

Here are the blog posts:

And the key points I extracted from those three blog posts:

Best practices to have long-lived tests

“Acceptance tests must meet the needs of several groups, including the users and the developers. Long-lived tests must be written in the language of each group, using terms users will recognize and a programming language and style in which the developers are competent.”

Utilities such as recording tools can help reduce the effort required to discover how to interact with the web application. The open-source test automation tool Selenium (http://seleniumhq.org/) includes a simple IDE record and playback tool that runs in the Firefox browser. Recorded scripts can help bootstrap your automated tests. However, don’t be tempted to consider the recorded scripts as automated tests: they’re unlikely to be useful for long. Instead, plan to design and implement your test code properly, using good software design techniques.”

“Several years of experience across multiple project teams have taught us that the tests are more likely to survive when they’re familiar and close to the developers. Use their programming language, put them in their codebase, use their test automation framework (and even their operating system). We need to reduce the effort of maintaining the tests to a minimum. Get the developers to review the automated tests (whether they write them or you do) and actively involve them when designing and implementing the tests.”

Isolate things that change from those that don’t. For example, separate user account data from your test code. The separation makes changes easier, faster, and safer to implement, compared to making updates in the code for each test.”

“Robust tests can continue to operate correctly even when things change in the application being tested or in the environment. Web applications use HTML, so try to add IDs and CSS classes to relevant elements of the application

Try to avoid brittle identifiers, such as xpath expressions that rely on positional data. For example, /div[3]/div[1] becomes unreliable as soon as any of the positions change – and problems may be hard to identify unless the change is easy to identify.

Add guard conditions that assert your assumptions are still accurate. Design the tests to fail if any of the assumptions prove false.

Try to only make positive assertions. For example, if you expect an action to cause an item to be added to a list, assert that after the action the list contains the expected value, not that the list has changed size (because other functionality may affect the size). Also, if it's not something your test is concerned about, don't make assertions about it.

“Informative tests
Help your tests to help others by being informative. Use a combination of meaningful error messages and more detailed logs to help people to tell whether the tests are working as intended and, if problems occur, to figure out what’s going wrong.”

Taking screenshots of the UI when a problem occurs can help to debug the issue and disambiguate between mismatches in our assumptions vs. problems in the application.

Debug traces are useful for diagnosing acute problems, and range from simple debug statements like ‘I made it to this point’ to dumps of the entire state of values returned from the application by our automation tool. In comparison, logging is intended for longer-term tracking of behaviour which enables larger-scale thinking, such as enabling a test to be reproduced reliably over time.

Good error messages should say what’s expected and include the actual values being compared. Here are two examples of combinations of tests and assert messages, the second more helpful than the first:

1. Int actualResult = addTwoRandomOddNumbers();

assertTrue("Something wrong with calculation", actualResult % 2 == 0);

2. Int actualResult = addTwoRandomOddNumbers(number1, number2);

assertEquals(String.format("Adding two odd numbers [%d] and [%d] should return an even result. Calculated result = %d", number1, number2, actualResult) actualResult % 2 == 0);”

“My advice for developing acceptance tests for Web applications: start simple, keep them simple, and find ways to build and establish trust in your automation code.

The value of the tests, and their ability to act as safety rails, is directly related to how often failing tests are a "false positive." Too many false positives, and a team loses trust in their acceptance tests entirely.

Acceptance tests aren’t a ‘silver bullet.’ They don’t solve all our problems or provide complete confidence in the system being tested (real life usage generates plenty of humbling experiences). They should be backed up by comprehensive automated unit tests and tests for quality attributes such as performance and security. Typically, unit tests should comprise 70% of our functional tests, integration tests 20%, and acceptance tests the remaining 10%.

“Lots of bugs are discovered by means other than automated testing – they might be reported by users, for example. Once these bugs are fixed, the fixes must be tested. The tests must establish whether the problem has been fixed and, where practical, show that the root cause has been addressed. Since we want to make sure the bug doesn’t resurface unnoticed in future releases, having automated tests for the bug seems sensible. Create the acceptance tests first, and make sure they expose the problem; then fix the bug and run the tests again to ensure the fix works.”

About Screen/Page objects

Effective test designs

By using effective test designs, we can make tests easier to implement and maintain. The initial investment is minor compared to the benefits. One of my favourite designs is called Page Objects (see PageObjects on the Google Code site). A PageObject represents part or all of a page in a web application – something a user would interact with. A PageObject provides services to your test automation scripts and encapsulates the nitty-gritty details of how these services are performed. By encapsulating the nitty-gritty stuff, many changes to the web application, such as the reordering or renaming of elements, can be reflected in one place in your tests. A well-designed PageObject separates the ‘what’ from the ‘how’.

BDD – Behavior Driven Development

Another effective test design is based on three simple words: ‘given’, ‘when’, and ‘then’. As a trio they reflect the essential elements of many tests: given various preconditions and expectations, when such-and-such happens, then I expect a certain result.

// Given I have a valid user account and am at the login page,

// When I enter the account details and select the Enter button,

// Then I expect the inbox to be displayed with the most recent email selected.”

To me all those points are valid ! And the best is that most of them aren’t bound to a technology, a framework or whatsoever.

I could apply those principles on different applications built using ASP.NET MVC, WPF, Java JSF with different frameworks like MSpec, Watin, White, Selenium, JUnit/NUnit

You might read more about this on the following posts:

Jun
26
2010

Jobping announcing StickyBeak

As said when we launched Jobping Open Source Short Urls Service, we at Jobping are committed to open source.

So last week we announced  StickyBeak, you might read more on the blog of Mark - Introduction to StickyBeak

StickyBeak is a logging tool for asp.net websites which logs information such as date, http method, url, User.Identity.Name, IP Address, unique session Id, unique browser Id, header values, querystring values, posted form values and cookie values for every request.

Here is a screenshot of the administration page,which lets you see the logged activity on your site.

StickyBeak is a complementary tool to the excellent elmah from Atif Aziz

We are using elmah on Jobping to log exceptions that might happen on the site, but we also wanted a raw record of each request made to our site, to make our troubleshooting life easier.

You can download the source and binaries from StickyBeak on CodePlex.

Jun
3
2010

Build and Deployment automation, VCS Root and Labeling in TeamCity

As you might now from reading my blog I tend to automate as much as I can.

Why? Because I hate to do repetitive tasks. First because it is boring, at least for me, and as a developer we have more interesting things to do. Second because executing repetitive tasks tend to be error prone.

So last week I decided that it was enough for me to have to create manually a subversion tag for Jobpingweb site then also took the time to do the same for my portal Tech Head Brothers.

At Jobping we are using TeamCity and Subversion. We use it as our Continuous Integration system but also to deploy to production server in one click. Something I promised to talk later on in more details.

So it was relatively easy to configure TeamCity so that after build/deployment process it tags our subversion.

First of all, I realized only the other day the way TeamCity works with VCS root 

A VCS Root is a set of settings that defines how TeamCity communicates with a version control (SCM) system to monitor for changes and to get sources for a build.

We are using the convention of trunk, branches, tags in our Subversion server (which is the great Visual SVN Server). In the past I always set the TeamCity VCS Root to our myproject/trunk url, and I have seen lots of people doing so on different websites/blogs…

At this point I realized that I missed a point with TeamCity VCS Root is that it contains Root in it’s name. So I might be using myproject/ in place of myproject/trunk as the VCS Root. But wait, if I do that TeamCity agent will make a checkout of my whole Subversion repository!

And here comes the VCS Checkout rules, which you can configure on every project which is using the VCS Root

4663096481_231787d2d1_o[1]

So in my case it looks like that

4663731014_a4945d38d0_o[1]

Which specify that for that particular build I want to checkout from my VCS Root extended with trunk to the build folder /. So with that I restrict the checkout to the trunk. Good

Now back to my first topic, which was to automate the subversion tag creation when our build is successful which is done using TeamCity VCS Labeling.

Here is how we set it up for our staging build

4663125553_c725cbc3dc_o[1]

For sure we have another one for our production build.

And here is the result in Subversion

4663756592_592d22d287_o[1]

Another thing that I will not forget as it is automated

One last issue that I had which you see only if you register to get info about failed build in TeamCity is the following

[TeamCity, LABELING FAILED] Staging - CI Trunk, Unit Tests, Deploy #1072

Jetbrains.buildServer.vcs.VcsException:

Labeling the path 'trunk' to 'tags/staging-1072' has failed with the error: svn: MKACTIVITY of '/svn/!svn/act/7caf50f8-2801-0010-9e80-1fedd46c5a33': 403 Forbidden

With this error message it was then easy to figure it out. I just had to modify the access right of the build user to have read/write access right and not only read.

Jun
1
2010

Using Gmail as TeamCity smtp server

Some time ago when I had to reinstall our Jobping Continuous Integration server, which is Team City I also decided not to reinstall any smtp server but to use Gmail server.

Here is the configuration that I used, which worked perfectly for me

4656773327_09a7eed279_o[1]

Use SMTP port 465 and TLS (SSL) !

May
19
2010

ASP.NET MVC 2, MSpec and Watin

The other day I posted about “Automated functional tests using Watin and MSpec” which we do at Jobping as a spike to automate our functional tests on our ASP.NET MVC 2 site.

Yesterday evening I was facing an issue in my base class WebBaseSpec which led to really strange side effects. Basically when I was running one unit test alone it was Green, running all or more than one unit test will fail miserably with the well known STA issue of Watin.

So I thought that I had an issue with the ReSharper MSpec plugin but after some discussion with Alexander GroßI realized that the second failing test was showing another issue than the STA issue.

Going further I realized that when I was checking the following

It should_direct_user_to_aboutus_page = () =>
    Browser.Uri.Route().ShouldMapTo<HomeController>(x => x.About());

First I needed to call the ASP.NET MVC RegisterRoutes

MvcApplication.RegisterRoutes(RouteTable.Routes);

which was done in the constructor of my WebBaseSpec class.

protected WebBaseSpec()
{
    MvcApplication.RegisterRoutes(RouteTable.Routes);
    InitBrowser();
}

That’s was the problem, I was registering the routes several time, one time per test. So first one was ok, second one was failing…

So I modified it to the following, ensuring that the routes were registered only one time!

private static bool registered;

/// <summary>
/// Initializes a new instance of the <see cref="WebBaseSpec"/> class.
/// </summary>
protected WebBaseSpec()
{
    if (!registered)
    {
        MvcApplication.RegisterRoutes(RouteTable.Routes);
        registered = true;
    }
    InitBrowser();
}

Now I can run all my functional tests again

4621024158_d2c99039a0_o[1]

May
14
2010

Jobping Open Source URL Shortener. Goes to Version 0.5

We have updated our url shortener for Jobping. jobp.in has moved along to Version 0.5. While maintaining as little features as possible!

Since the initial version we have placed a restriction(web.configurable) on the domain names that the shortener will shorten. We did this so only domains under jobping.com would be processed by the shortener. We wanted to maintain the integrity of the jobp.in domain. With this in place you can be sure that if you click a link shortened by http://jobp.in  it will always go to our site www.jobping.com site.

This version also includes a new custom style, which looks awesome and is now slick and styled inline with our main site Jobping.

4603509097_c8c3439491_o[1]

The new version can be downloaded from codeplex here: http://jpurlshortener.codeplex.com/

May
12
2010

Fundamental Laws from David S. Platt on MSDN Magazine

Yesterday I got the new issue of MSDN Magazine in my mailbox and as often I started to go quickly around it to get an overview of what kind of subject’s it talks about. And as often I end up at the last page’s article which is the first I am reading.

This time David S. Platt is writing about “Fundamental Laws” which start like that

Whenever I find a program or Web site that sucks, it’s invariably because the developer or designer forgot the user’s goals and started embellishing the program for its own sake.

This reminded me a discussion I had a year and a half ago at Christmas time when my brother was back from Australia. We were discussing about what became Jobping.

And as you can read fom Jobping  press release, “Jobping launches niche job website listing Microsoft skilled vacancies”, it is one of our priority:

More features and functions based on user feedback and requirements will be implemented quickly as Jobping takes an organic and user oriented approach to product development.

From David

Your software has zero value in and of itself. Nothing. Nada. Zero point zero zero. The only value it ever has or ever will have is the degree to which it enhances the happiness of your user in some way

So when you develop software you’d better understand and listen to the problem of your users to delight them and enhance their happiness.

May
4
2010

Jobping Open Source Short URLs Service

We at Jobping use different Open Source projects so we thought it would be nice to participate by giving back also to that eco-system. This is why we realized Jobping Open Source Short URLs Service 

The project goal was to have our own branded short URL service: http://jobp.in
As we leverage Twitter to have an easy way for job seekers to follow the different published offers, we decided that having our own branded url would be nice. Job posters now get an extra few characters for each tweet and readers can rely on our short URL as a trusted domain that leads them to our main site

Our shortener, http://jobp.in, only accepts long URLs that are in our jobping.com domain.

As it is an Open Source project hosted on Codeplex http://jpurlshortener.codeplex.com, anybody can get its own deployed.

Jobping URL shortener works like other URL shortener services, it takes a long URL and makes it really short. When a user requests one of our short URLs e.g http://jobp.in/g the URL shortener service will redirect the user to the long URL. It issues a standard 301 redirect, an efficient and search engine friendly method for redirecting the user to the long URL location.

If you want more technical details you might read more on the blog of Mark : “Announcing: JP URL Shortener. Open source MVC.NET 2 C#

Stay tuned, we will be contributing more projects just like this to the open source community.

Apr
27
2010

Press Release - Jobping launches niche job website listing Microsoft skilled vacancies

Press Release

Sydney, Australia - April 22, 2010 - Last week, Jobping, a new job posting web site aimed specifically at job seekers and employers who work with Microsoft technologies, was released into public beta.

Jobping currently focuses on the Australian market and aims to bring a better quality of candidate to a posted vacancy via a niche, industry targeted approach.

The site is unique, user friendly and streamlined when compared to the larger job post boards. For instance, publishing is done in a couple of clicks and the job is instantly broadcast through Twitter, Facebook and job indexing sites such as Indeed and CareerJet. Recruiters are also able to add their company Twitter feed to a job post in order to cross sell other vacancies all in one place.

From a job seeker point of view Jobping searching works just like today's search engines with specific job filtering options. Job seekers also benefit by being kept up to date in a variety of ways including through Rss, Internet Explorer Web Slice, Twitter or Facebook. Similarly, job seekers are able to apply for a position using their LinkedIn profile, saving time and eliminating the need to keep two separate resumes up to date and they may optionally attach a traditional pdf or word resume.

More features and functions based on user feedback and requirements will be implemented quickly as Jobping takes an organic and user oriented approach to product development.

Jobping will remain free during the beta period which will continue for 3-6 months. Advertisers utilising the site during the beta period will be rewarded through special discounts once the pricing structure is introduced.

Visit us on www.jobping.com !

The team behind Jobping is: 

  • Mark Kemper - Microsoft Certified Professional Developer .Net Framework 2.0 Enterprise Applications Developer.
  • Ally Colqhoun    - Graphical designer front end developer.
  • Mathieu Kempé - Former Visual C# Microsoft MVP (2004-2006).
  • Laurent Kempé - ASP.NET Microsoft MVP since 2001.

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent was awarded Most Valuable Professional (MVP) by Microsoft from April 2002 to April 2012.

JetBrains Academy Member
Certified ScrumMaster
My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List