Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Coded ui tests 测试清理的目的是什么_Coded Ui Tests - Fatal编程技术网

Coded ui tests 测试清理的目的是什么

Coded ui tests 测试清理的目的是什么,coded-ui-tests,Coded Ui Tests,谁能详细告诉我什么是测试清理?为什么我们要使用它? 为什么在初始化后使用 它实际上是做什么的 请详细告诉我测试清理是每次测试后运行的代码 测试清理是在声明测试的同一类中声明的。此外,在TestCleanup中使用的任何断言都可能导致测试失败。如果在可能导致测试失败的同一位置检查每个测试的值,这将非常有用 [TestCleanup] public void CleanUp() { AppManager.CheckForHandledExceptions()

谁能详细告诉我什么是测试清理?为什么我们要使用它? 为什么在初始化后使用 它实际上是做什么的


请详细告诉我

测试清理是每次测试后运行的代码

测试清理是在声明测试的同一类中声明的。此外,在TestCleanup中使用的任何断言都可能导致测试失败。如果在可能导致测试失败的同一位置检查每个测试的值,这将非常有用

[TestCleanup]
      public void CleanUp()
      {
         AppManager.CheckForHandledExceptions();
      }
以下是需要考虑的重要事件:

[ClassInitialize]
      public static void Init(TestContext testContext)
      {
         //Runs before any test is run in the class - imo not that useful. 
      }

[TestInitialize]
      public void Init()
      {
         //Runs just prior to running a test very useful. 
      }
我通常使用TestInitialize在测试之间重置uimap,否则控件引用可能会过时

下一步是在程序集中的所有测试运行完毕后运行什么(非常适合检查未处理的异常或可能关闭应用程序)

因此,如果您通过MTM运行100个测试,在最后一个测试完成后,AssemblyCleaup将运行,还要注意,此方法有点特殊,它在每个程序集中声明一次,在它自己的类中,在类上具有[CodedUITest]属性

[CodedUITest]
   public class TestRunCleanup
   {
      [AssemblyCleanup()]
      public static void AssemblyCleanup()
      {
         AppManager.CloseApplicationUnderTest();
      }
   }

在询问研究助理问题之前,请先阅读并了解本网站的工作原理。谢谢,祝你好运这似乎是离题的,因为Stackoverflow是一个关于编码的网站。你有一段代码和一个问题吗?把它贴在这里。我不认为它离题了。他在问一个与代码相关的问题。