1

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?

Community
  • 1
  • 1
  • As what user is the scheduled task running? As what user did you run it manually? – Lieven Keersmaekers Jun 16 '15 at 15:01
  • Both administrator. Or I'm not getting you're reply. You can talk to me in Dutch if you can message me. – Robert Maclean Jun 16 '15 at 22:26
  • Extra note...when using a RDP to the VM the tests run, but only if the screen is not minimized or interrupted. I don't want to use a Remote Desktop connection. – Robert Maclean Jun 16 '15 at 22:28
  • It appears to me that you don't have an active session when the tests run. That's kind of the same problem as in the link you posted yourself. I have no idea why minimizing the screen would have that effect though so a bit at a loss there. One thing you might try is to have a dedicated physical computer connecting to the VM and keep a session open to it. You can lock the physical device to keep things secure *(more or less)*. – Lieven Keersmaekers Jun 17 '15 at 05:15

2 Answers2

1

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.
Thomas Bouman
  • 608
  • 4
  • 17
0

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.

Community
  • 1
  • 1
  • and now my test agent status is "Disconnected" and my test controller configuration tool freezes. Frustration all over! – Robert Maclean Jun 19 '15 at 15:38
  • okay it's online again, so Test Agent seems to work, but I still don't know how to test a category of tests which I customized in my code without an active desktop. – Robert Maclean Jun 22 '15 at 07:51
  • _"but I still don't know how to test a category of tests which I customized in my code without an active desktop."_ You cannot run Coded UI tests without an active desktop. – Thomas Bouman Jun 22 '15 at 08:15
  • So...I've been told, but I've also read there is a workaround for this. At least not using a RDP connection to the VM. – Robert Maclean Jun 23 '15 at 07:10
  • The thing I can't get my head around is, that it's not possible to schedule my tests and run them without the need to use one screen for this from my own desktop. – Robert Maclean Jun 23 '15 at 11:25
  • It is possible to do that, you can have an active desktop session without having it visible to anyone. As provided in my answer, MS offers a tool to login with an active desktop session, without you having to RDP to run the tests. You still need something to run the tests, but that can be automated easily as well. – Thomas Bouman Jun 23 '15 at 13:27