简体   繁体   中英

Coded UI Tests not running properly when run together

I have a bat files that executes the coded ui tests . The problem is these tests run properly when run separately one after another. ie comment the 30 odd test cases in the ordered test except one and run the batch file. It will pass that test case. But if I uncomment all these test cases and run it together one after another it fails. What might be the possible cause of this error. Please help. I have been going with this for almost one week and i have spent loads of hours.

I have this problem once. Maybe your test dependent on another test, maybe your first test is deleting data and after that second test trying to get data that deleted, another solution is try to comment test one by one and run together you will cath test that causing problem Hope helps!

Perhaps tests are dependent on each other. If they are reading/writing from/to files, that's definitely something to look out for. Also, remember that the constructor is called once for the entire test class. (Similarly, inline variable definitions are called once for the entire test class). Of course [ClassInitialize] will also only be run once for all tests. If all of that logic is moved into [TestInitialize], I would expect your problem to be resolved.

I had this problem when I was using a static class to hold an instance of the UI Map.

Here is the solution:

[TestInitialize]
      public void Init()
      {
         AppManager.ResetUIMap();
}

Then:

public static void ResetUIMap()
      {
         _map = new UIMap();
      }

You can't run coded UI test concurrently on the same machine, since they interact with the UI. Run them on multiple machines to run in parallel or create some VMs etc.

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