How to run scheduled Coded UI Tests on Virtual Machine without having a RDP connection

1.9k views Asked by At

Situation in short:

  • Virtual Machine with Visual Studio 2013 installed. PowerShell script runs on the VM to execute Get Latest, Build and Execute Coded UI Tests. Windows Scheduled Task to execute PowerShell nightly.
  • auto-logon is enabled (or I'm doing something wrong?)
  • yes, I've read post Is it possible to run Coded UI tests without having to connect via remote desktop?
  • I've seen posts about TCM. Does this help and how can I use it in my situation?

I made some tests in Microsoft Test Manager and I also executed and recorded them. I've loaded these tests in a test project (and changed the script providing categories and custom checks). I then categorized these (as Development or Acceptance). I executed out using a PowerShell script on a VM (with Visual Studio 2013 installed) with following actions:

  • Get Latest
  • Build
  • Run latest build with a selected set aka category using mstest.exe

So far everything is going perfectly. All the tests pass. However, when I create a Scheduled Task on my VM run the PowerShell script everything fails because of a missing session. Do I have the VM (I have no knowledge of Virtual Machines) then unlock or something?

Side-Note: I also tried to fix this with a Test Agent and Controller, but once I had installed these, all other users of TFS lost their rights, so I prefer not to do this again.

I would be very grateful if you know something that can solve this. I spent hours on Google finding a solution for this issue, but no solution helped me.

Do I need to provide more information?

2

There are 2 answers

0
Thomas Bouman On

The problem you're seeming to have is that the testagent is not setup correctly. You need an active desktop session for Coded UI to be able to run (it needs it to perform all the actions such as clicks).

Microsoft has some nice info about setting up your test agent here.

But to tackle your exact problem of the test failing because of a missing session I'd suggest the following:

  • Run AutoLogOn.exe from the sysinternals suite (can be found at http://live.sysinternals.com/). It will automatically log in with specified user when the machine starts, and keeps the desktop session active.
6
Robert Maclean On

Alright...I'm making progress. I've installed test agent and controller. It's all running fine. Next I've opened Lab Center on my own MTM to create a new environment.

Test Controller is found, but I receive the message in this post "Microsoft Test Manager cannot install test agent on these machines" when creating new Lab Center environment

File and Printer sharing exception is enabled. I don't get the other message. I don't understand what is wrong. Maybe I'm completely on the wrong track and it's not necessary to use the Lab Center. Then the only remaining issue is the non-active desktop issue.