views:

470

answers:

3

I'm trying to integrate running Fitnesse tests from MSBuild im my nightly build on TFS.

In an attempt to make it self contained I would like to start the seleniumRC server only when it's needed from fitness.

I've seen that there is a "Command Line Fixture" but it's written in java can I use that?

A: 

What about writing a simple .NET app that does a Process.Start("selenumRC commandline") which gets run by your build script?

If you aren't too far down the Selenium route; might I suggest that you look at similar .NET browser automation tools; specifically WatiN or ArtOfTest. The "stacks" in these are completely .NET, so getting them running on different machines is much easier.

David Laing
+1  A: 

I think you might be able to. You can call any process easily in MSBuild using the task. However, the problem with doing this is that the exec task will wait for the Selinium process to finish before continuing, which is not the bahaviour you want. You want to run the process, keep it running during your build and then tear it down as your build finishes.

Therefore, I think you are probably going to need to create a custom MSBuild task to do this. See the following post for an example of a tasks that someone has created that will run asynchronously returning control back to the build script:

http://blog.eleutian.com/2007/03/01/AsyncExecMsBuildTask.aspx

And for an example of calling a Java program from MSBuild (but in this case synchronously) take a look at my task that calls Ant from MSBuild here

http://teamprise.com/products/build/

As part of your MSBuild task, you will want to output the process id that you created to an output property so that at the end of your build script you can call another custom MSBuild task that kills the process. It can do this by looking for the process id passed in as a variable in MSBuild and then call Process.Kill method i.e.

Process process = Process.GetProcessById(ProcessId);
process.Kill();

That said, you would need to be careful to ensure that your kill task was always executed in MSBuild by making sure it was included during error paths etc in the build. You could probably make things a bit more resilient by making the selenium RC starter task look for other seleniumRC processes and killing them before starting a new one - that way if a process didn't get closed properly for some reason, it would only run until the next build.

Anyway - my answer sounds like a lot of work so hopefully someone else will come up with an easier way. You might be able to create the seleniumRC process in the test suite start up of the FitNesse tests and kill it in the suite tear down, or you might be able to write a custom task that extends your FitNesse runner tasks and fires up seleiniumRC asynronously before running the test process and then kills it afterwards.

Good luck,

Martin.

Martin Woodward
+1  A: 
HAXEN