Thursday, April 19, 2007

Test your web application with Selenium

Thanks to Skills Matter I attended a Selenium session tonight. Selenium is a tool for automated web testing. The session was led by Erik Doernenburg. He's a ThoughtWorker, so I knew the presentation was going to be good quality. Not only did he present what Selenium is, but he also presented many good techniques for using it with your project.
Some of my notes below:
  • All important browsers are supported
  • All important languages are supported
    • He used Java at the talk
  • SeleniumIDE is the tool for recording tests
    • It's not necessary to use it, you can write tests in your favourite language
    • SeleniumIDE is only for Firefox
  • You need to start the Selenium server in order to run tests
  • Many methods available:
    • createCookie
    • dragdrop
    • fireEvent
    • assertTitle
  • There is a concept of locators
    • It means the way to locate your DOM elements
    • name, id, identifier
    • document.forms['myForm'].myDropDown
    • XPath
    • link text
    • css selectors, css = a[href="#id3"]
  • Selenium server sets the proxy in your browser, so your browser asks the server for everything
  • It's bad for performance testing
  • Good for testing multiple browsers
  • There was some great advice, which I think applies for all kinds of functional tests
    • "Test what you want to test"
    • Which means, if you have already tested creating users in a functional way, you don't need to test it functionally again
    • So, you can actually use your production code to change the state and then functionally test what you're actually testing
    • Saves time
    • Makes your tests less fragile
    • Cool!
  • It's a good pattern to have classes for all of your pages
    • WelcomePage
    • DailyViewPage
  • And one class for your test
    • AddItemToBasket
    • CreateUser
  • Your test classes will then use your page classes
    • welcomePage = WelcomePage()
    • welcomePage.setDailyView()
  • There are other ways of functionally testing your web application
    • HttpUnit which asks your web server, not the browser
    • Use a Presentation pattern
      • have only thin presentation layer
      • test only your "event handlers" methods
  • It's common practice for QA people to create Selenium scenarios
  • You can start your TDD session with a failing Selenium test

Monday, April 16, 2007

RuPy 2007

  • A well-organized conference
  • It was interesting to meet so many "dynamic" people
  • Many Ruby people attended Python talks and vice-versa
  • Maybe instead of having two separate sessions it would be better to have one with shorter talks?
  • Poznan is a very nice city, almost as nice as Wroclaw :)
  • The quote of the conference:
    • "Look, all of the Ruby people have Macs!"
    • "Yeah, they are better paid..."

Christopher Arndt talk on TurboGears
  • TG is very similar to Rails
  • TG has support for testing, unfortunately it wasn't shown during the talk
  • as with all (?) Python web frameworks, you can't use Python for implementing views
  • it's better with Rails, that you don't have to change the language for your views
  • It uses SqlObject which is ok, but doesn't give you the same level of abstraction as SQLAlchemy (ActiverRecord-like ORM library) does
  • They want to switch to SQLAlchemy soon, cool!
Ruby/Rails tools that help
  • by Cloves Carneiro Jr.
  • a very good presentation
  • the speaker is a good example of a happy Rails programmer ;-)
  • I was already familiar with all of the tools, but I learnt some details
  • Capistrano
  • Rake
  • Subversion
  • autotest (zentest)
    • perfect integration with growl notifier, very cool!
  • rcov
  • TextMate talk
  • as far as I know is the biggest Django application in the world
  • many performance challenges
  • "Share nothing" architecture
  • Lots of caching
  • The first version was in Java - "unmantainable", switched to Python
  • not many tests
  • experiments with WSGI tests
  • they use an old Django version, can't take advantage of new features (testing support)
  • a nice introduction to RadiantCMS
  • it has a good system of extensions
  • it's a Rails application, so you can easily extend it with your models/controllers
  • there is a wysiwyg plugin

Domain specific languages with Ruby by Jan Szumiec
  • Jan presented a very agile way of creating a valid DSL
  • The pair programming part (with Olle Jonsson) was very funny :)

Developing with IronPython and Windows Forms by us (Michael Foord and Andrzej Krzywda)
  • The talk was a little bit too long (90 minutes)
  • I enjoy coding live :)