Why to Use FitNesse or ATDD on Top of Selenium?

For Web Application development Selenium is a defacto tool for functional testing with its click and capture capability through browser plugin. At the end of recording, Selenium script can be converted in a test-case in almost any programming language.

Immediately after you begin talking about functional testing people jump on the tools and would like to know what tools you are using or going to use.

And in practice that’s how it works. Somebody will say let’s use Selenium and somebody else will come up with a suggestion to use Xebium or FitNium. In some projects which-tool-to-use becomes very clear within a day but unfortunately fewer understand the business-case of using Xebium or FitNium instead of pure Selenium.

This post tries to answer following questions:

  • What’s the need to cover Selenium with FitNesse to begin with?
  • In practice does FitNesse + Selenium work any better compared to pure Selenium, based on the reasons mentioned in last question?

Why Selenium + FitNesse (Xebium or FitNium)?


The basic idea of using FitNesse on top of Selenium is to enable a tester or a customer to start writing a functional test cases even before developers start coding. That’s a big advantage as testers then are able to utlise their time to do some worthwhile work at the beginning of the Sprint.

That way FitNesse test cases become the concrete acceptance criteria in front of developers too.

This is the basic fundamental idea of “ATDD

Here is a screenshot of a Xebium (can convert FitNesse test case into Selenium script and vice-versa) test case:

Above test case is written in following pattern or DSL:

start browser <browserName> onURL <url>

ensure do open on ...
ensure do verifyTitle on ...
ensure do verifyTextPresent on ...

stop browser

The test case language is far simpler than any other technical test counterpart. As a result any tester can easily learn and write test cases using Fit framework. Even though the premise is to enable people without any technical know-how to write acceptance test cases, it doesn’t look that easy for a non-technical person by looking at the DSL and its essential grammar. It requires some learning curve and I am not sure if every non-technical person will be wiling to write a test case using FitNesse based DSL.

Better choices for Selenium + ATDD

In my last blog “Distributed Agile: Acceptance Test Driven Development (ATDD) in Practice” I talked about ATDD in practice for Distributed Agile teams using “Behavior Driven Development (BDD)” frameworks like “easyb”. Tester/customer write the test cases in pure English based DSL and developer and tester then fill the implementation of the test case.

Here is an “easyb” scenario which a customer/tester writes and you see how easy it’s to write and explain:

scenario "User submits valid credentials and gets to the home page",{
    given "Open the login page",{
    }
    when "User enters valid credentials and submits", {
    }
    then "Album List specific to the user is shown to the user", {
    }
}

As I said implementation has to be written by a developer, here’s a Selenium implementation in Grails, using Page Object Pattern,

def loginPage
def homePage
scenario "User submits valid credentials and gets to the home page",{
    given "Open the login page",{
        loginPage = LoginPage.open()
    }
    when "User enters valid credentials and submits", {
        loginPage.username ="john"
        loginPage.password = "pass1"
        homePage = loginPage.submit()
    }
    then "Album List specific to the user is shown to the user", {
        homePage.verifyPage()
    }
}

Conclusion

We can use BDD based frameworks to our advantage to write Selenium test cases in ATDD fashion which brings a big change the way acceptance test cases are written and executed. Also in practice, it’s much-much easier to get some direct interaction of PO with the application without being too verbose.

ShriKant Vashishtha is an enterprise Agile Coach, IT strategist, trainer, thinker and hands-on geek. He is passionate towards enterprise Agile transformation, quality aspect of software development including TDD, refactoring, Continuous Delivery, DevOps and Test Automation. He can be reached at vashishtha_sk@yahoo.com.

Tagged with: , , , , ,
Posted in Agile, ATDD, BDD, Distributed Agile, Functional Testing, Grails, Patterns, Testing
2 comments on “Why to Use FitNesse or ATDD on Top of Selenium?
  1. Cirilo Wortel says:

    Hi ShriKant, IMHO the reason why Fitnesse is a tool that helps you write tests in advance is not that the Xebium or Fitnium DSL’s are so simple, these are just other ways of formatting Selenese. The real reason is that Finesse provides the user with great options to structure and document testcases as well as report on test execution.

    Now what really brings added value is the possibility to add your own DSL on top of the Xebium/Fitnium format. This can simply be done with Scenario tables. The mechanism allows you to practically choose any (table) format you like as an abstraction on top of your Selenium scripts.
    For Instance the example you give in your blog, would turn out like this when using Fitnesse’s Scenario tables:

    | script |
    | given a user opens the login page |
    | when he submits correct credentials |
    | then user specific information is shown on the homepage |

    This simple mechanism, which besides readability also increases maintainability (by having reusable scenario’s), also supports variable substitution and data-driven testing.

    Just by understanding Fitnesse’s Wiki markup practically any non technical person can write testcases. If creating the actual Selenium layer underneath this abstraction is still to complex for the functional testers on the team, because it requires some xpath and/or css knowledge, you could decide to leave that part to the developers or automation experts.

  2. I understand FitNesse provides a lot many options and is very flexible. However that’s the very reason I may not find it very useful for business users. For them I believe simplicity or limited options to think works better than flexibility.

    Within two many FitNesse choices, the one simple choice may get lost. In case of BDD, I just need to think in terms of what’s needed at the end which makes my thinking pretty simple. Even after being technical people, some developers find the concept of FitNesse difficult to understand. Though we have talked a lot in favor of FitNesse for years that it provides a business user to talk in business language with technical world, in real sense I haven’t seen a single project or Product Owner who seem to be comfortable with the whole concept.

    BDD is far simpler way of thinking and that’s what I like about it.

2 Pings/Trackbacks for "Why to Use FitNesse or ATDD on Top of Selenium?"
  1. […] step ahead towards ATDD. However this team was not using BDD or tools required for ATDD and was not planning to move […]

  2. […] step ahead towards ATDD. However this team was not using BDD or tools required for ATDD and was not planning to move […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

CommentLuv badge

Welcome to Sampreshan
Technology Strategist, Speaker, Scrum/XP/Agile Trainer Coach and Trainer
Your interest areas
Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: