Saturday, 19 January 2013

Using TeamCity and NUnit to Start WebServer, Run Selenium Tests and Stop WebServer

Following the move to split the TeamMentor Brower automation tests into the UnitTests_WebAutomation repository, I just committed a bunch of git pushes (from here up to here) and customized a TeamCity project , so that TeamCity EC2 box will:



1) automatically pull both code and tests repositories (with git commits triggering the pull)

image

2) Build both solutions files:

image

3) Run the NUnit project (which contain the Selenium Unit Tests)

image


Now ....

There were a couple special extra steps/tricks required to make this work:

The git pulls are done into separate folders (see below the TeamCity Git 'checkout rules')

image

These use the special syntax: +:.=>/{Target folder}  

image


This means that (In the EC2 server) each repository has it own folder

image


The agent that runs the tests is a desktop-based windows process (i.e. not the default TeamCity Service Agent)

This Desktop agent is is explicitly mapped to this project:

image

Here is how the Desktop Agent was started: (the screenshot below is from the EC2 server where TeamCity is installed)

image

The NUnit SetupFixtureAttribute is used to start and stop the webserver (note how there is a dependency on the TeamCity clone paths)

image

The code above will execute before all tests, and the code below will execute at the end

image

The actual local port is now set to a random value, which ensures that there are no hard-coded ports/paths in these UnitTests:

image

And finally here are Michael's Selenium tests, that (for example) test the Login sequence:

image

What is really cool about this is that the whole process is now triggered from Git pushes (including starting and stopping the local instance of Cassini)

image
Post a Comment