Thursday, December 24, 2009

Design of Selenium tests for ASP.NET: Running UI tests as a part of continuous integration.

To keep UI tests up up to date it is needed to maintain them continuously. Build should be verified against UI tests every day and if something is broken – team should know what happened immediately. Only with such strategy give a chance for UI tests to survive. Just think, you are about to release build, it is late afternoon, it is needed to verify this build by QA and you realize that some of tests are broken (worth – if it broken by with strange errors). Will you fix this tests? NO. And another situation – you have just committed your changes and some automated system sends you e-mail that one use case is broken exactly after your commit. Will you fix it? Yep - it is very easy to find source of the problem.

Given all this, it is have no sense to have UI tests without automated continuous integration. And lucky we are it is possible to set up this procedure with only open source tools.

  1. Scheduler and viewer of builds - Cruise Control .NET
  2. Console client for Subversion
  3. Nant as build system
  4. Gallio as test runner
  5. PsExec tool to open browsers on remote computers.

Here are the solutions to main issues of running Selenium Grid on CCNET:

1) CCNET is that its worker process is implemented as windows service. Browsers just can't start without desktop. This can be resolved by PsExec tool, which can run processes in desktop session of particular user.

2) CCNET service should be runned under user, which have access to all servers, where remote controls will be executed.

3) PsExec shows window with terms of use first time, so exec it manually before using it with service.

The example of CCNet config file can be found here. And all builds scripts which download latest version of sources, adjust configuration files, build application and tests binaries, starts selenium grid on server and slave computers and run tests are here.

Build in Sample application starts every time after code commit. But if your tests take more then 10 minutes to run – divide your tests into 2 tests suits – one for checking after commit, and one for checking every night – this still will keep your tests up to date.

All sources are available in design-of-selenium-tests-for-asp-net solution.

0 comments: