问题
I want to intervene execution of a coded UI test in C# by keyboard or mouse interactions. For example I would like to pause a test by pressing Tab key and continue to it when I press Tab key again . Thank you very much in advance.
回答1:
Since you mentioned in a comment that you want to pause the test in order to do other things on your computer, I agree with Coding Nawab's answer of setting up a virtual machine on your computer and running the tests on that.
As long as the test is running on the virtual machine, you can do anything you like with your computer outside of the VM instance running the tests. For instance, I'm running an automated test on a VM as I write this.
回答2:
I don't know about the tab button to stop and play.
In VS you can run the Coded UI test in debug mode, set break points, step through the code.
MTM is used for manual testing. MTM allows you to play steps at a time.
The Coded UI test can easily fail if you interact with the mouse and keyboard while the test is running at the wrong time.
One option I do see but would require a bit a coding and testing; is to create a windows application that will have a pause and play button. In code before each action check if the pause button is clicked. You can also extract the logic to check for pause and play to the database so this way the windows/web application can be on another pc.
回答3:
If your concern is to do something between a long running test as you mentioned in your later post, the solution is to set up a virtual machine and run your tests in the virtual machine so that your machine can still be used.
Coded UI test run is managed by "Playback"
And as you can see in the link, there is no Pause and Resume method on it as its not designed to do that.
来源:https://stackoverflow.com/questions/16962809/coded-ui-test-c-manual-intervention