简体   繁体   中英

manually change coded ui tests

I use VS2012 for my website. I want to record methods ans assertions and then change them manually for my needs. I tried this and added properties and variables and changed the methods' content and it worked fine, but then I tried to record another method and generate the code - and it deleted everything I did because it did not match the UI map. Is there a right way to do it?

Do not edit the code in the uimap.designer.cs file, there is a comment at the top if it saying that it is a generated files and edits will be lost. Each time a new action or assertion is recorded the file is regenerated from the uimap.uitest file. The file is also regenerated if changes are made with the UI Map editor.

In many cases changes can be made using the UI Map Editor (double click on the uimap.uitest file) in solution explorer). There are 9 icons for various edits just above the actions panel, also available by right-clicking. Many more changes can be made by changing things in the properties panels for the actions and uimap controls.

If the uimap editor is not sufficient, then use the command (by icon or right click) to move an action into the uimap.cs file. Then exit the uimap editor, saving changes. Now the code in the uimap.cs file can be edited as required. Note that the uimap.designer.cs file and the uimap.cs files both have partial class UIMap near their top. After using the "Move code to UIMap.cs" command I recommend saving all files so that the uimap.designer.cs file is regenerated. Not saving the files can leave the "*.cs" files in an inconsistent state so that spurious errors are reported as the code in the uimap.cs file (and other files) are edited.

It is also possible to edit the uimap.uitest file as an XML file, but make a back up first as it is easy to break the file.

The phrase " it deleted everything I did because it did not match the UI map " in the original question is, I believe, misunderstanding what Coded UI is doing. There is no check for whether things match. Just regeneration of the uimap.designer.cs file after changes are made to the uimap.uitest file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM