Is it possible to run Coded UI tests without havin

2019-03-09 21:55发布

I'm attempting to automate Coded UI tests.

My test controller launches the tests on a remote test server, which I normally access via a Remote Desktop connection.

Is it possible to run the Coded UI tests without having to connect via remote desktop?

Currently, the tests only run when I have connected via Remote Desktop, and the window must be open. When I close the Remote Desktop session, the tests do not run.

If it isn't possible to run coded UI tests without remote desktop, how can I automate connecting via remote desktop?

Thanks

8条回答
贪生不怕死
2楼-- · 2019-03-09 22:19

From MSDN:

The computer that is running an agent on which you want to run coded UI tests cannot be locked or have an active screen saver.

If you are running your CodedUi Tests through Visual Studio (means that tests are executed under your account), I believe that you must be connected via remote desktop to the remote test server.

However, you can use Microsoft Test Manager to run your tests:

  1. Create a virtual environment.
  2. Setup your virtual machines so they can run automated tests.
  3. Install the Test Controller and Test Agent.
    -Set up the Test Agent to run as Interactive Proccess so it can run CodedUi Tests.
    -Set up the Test Controller to run with Microsoft Test Manager.
  4. Create a Test Plan through MTM and run tour tests in your virtual environment. There is no need to be connected in the remote server now, because your tests will run under the account that runs the Test Agent (note: you should create one for testing purposes).
查看更多
我命由我不由天
3楼-- · 2019-03-09 22:25

View/interact with the machine using VNC (for example, TightVNC )

查看更多
Animai°情兽
4楼-- · 2019-03-09 22:27

--Preferred Solution 1: Have a Hyper-V Client and simply run coded UI tests using a schedule task. No issues at all.

--preferred Solution 2: You need to have 2 VM. First remote desktop to VM 1, then from VM 1 remote desktop to VM 2 where Coded UI will be running. Once Coded UI started in VM2, simply disconnect VM 1. This will keep the session opened and will never have any issues

-less preferred Solution 3: Restart VM using command line. Make sue auto-log in is enabled on your VM. Have a scheduled task to run coded UI.

I used this method and found some of my tests breaks.

--least preferred Solution 4: use tscon.exe %sessionname% /dest:console I used this method but cannot guarantee that your test will run with out any issues

查看更多
乱世女痞
5楼-- · 2019-03-09 22:29

The easiest solution to this problem was simply to enable auto-logon on my test environment (there are a variety of ways of doing this depending on OS).

With auto-logon enabled, when I restart the test environment (using the 'shutdown.exe /r' command, which can be scripted), the test environment loads back up with an active, logged on session, and so the tests can run successfully.

For my nightly test automation, I enabled auto-logon on my test environment and scheduled a restart prior to test execution.

I have had no issues with this method - and it means I don't have to connect via Remote Desktop.

查看更多
放我归山
6楼-- · 2019-03-09 22:33

You can use VMware to run your coded ui tests. if you minimize the VM , test will still continue.

See this link for more details. http://www.binaryclips.com/2016/03/coded-ui-tests-executing-test-case.html

查看更多
叛逆
7楼-- · 2019-03-09 22:34

I ran into the same issue with our remote test machine, but our test machines run on Hyper-V. With Hyper-V, the solution is simply to connect via Hyper-V instead of Remote Desktop Connection, and closing the Hyper-V connection won't lock the computer.

Another suggestion would be to get around the fact that Remote Desktop automatically locks your screen. There's a quick bit about that here: http://homeservershow.com/remote-desktop-session-locks-workstation-after-exit.html

Basically, run "tscon.exe RDP-Tcp#0 /dest:console" in command prompt from the remote machine when you want to disconnect. The machine should remain unlocked and the tests will run just fine.

According to @Zatricion, that command can be generalized:

tscon.exe %sessionname% /dest:console
查看更多
登录 后发表回答