Search code examples
automated-teststeamcityvirtualization

How to use a virtual machine with automated tests?


I am attempting to setup automated tests for our applications using a virtual machine environment.

What I would like to have is something like the following scenario:

  1. Build server is automatically triggered to start an automated test for the application
  2. A "build" script is then run which consist of:
    1. Copy application files and a test script to a location accessible by the VM
    2. Start the VM
      1. In the VM, a special application looks in the shared folder and start the test script
      2. The tests script do its job, results are output to shared folder
      3. Test script ends
      4. The special application then delete the test script
      5. The special application somehow have the VM manager close the VM and revert to the previous snapshot
    3. When the VM has exited, process the result and send to build server.

I am using TeamCity if that matters. For virtual machines, we use VirtualBox but we are open to any other if needed.

Is there any applications/suite that would manage this scenario?

If there are none then I would then code it myself, should be easy but the only part I am not sure is the handling of the virtual machine.

What I need to be able to do is to have the VM close itself after the test and revert to a previous snapshot since I want it to be in a known state for the next test.

Any pointers?


Solution

  • VirtualBox does have a COM API. I have no experience with it, but it may be possible to use that. One option would be to have TeamCity fire off a script to do this. I'd suggest starting with NAnt (supported natively by TeamCity) and possibly executing PowerShell if necessary.