<small id='gZaYy'></small><noframes id='gZaYy'>

    <i id='gZaYy'><tr id='gZaYy'><dt id='gZaYy'><q id='gZaYy'><span id='gZaYy'><b id='gZaYy'><form id='gZaYy'><ins id='gZaYy'></ins><ul id='gZaYy'></ul><sub id='gZaYy'></sub></form><legend id='gZaYy'></legend><bdo id='gZaYy'><pre id='gZaYy'><center id='gZaYy'></center></pre></bdo></b><th id='gZaYy'></th></span></q></dt></tr></i><div id='gZaYy'><tfoot id='gZaYy'></tfoot><dl id='gZaYy'><fieldset id='gZaYy'></fieldset></dl></div>
      <bdo id='gZaYy'></bdo><ul id='gZaYy'></ul>
    <tfoot id='gZaYy'></tfoot><legend id='gZaYy'><style id='gZaYy'><dir id='gZaYy'><q id='gZaYy'></q></dir></style></legend>

      1. Robot Framework 中相互依赖的测试自动失败/不执行

        时间:2023-09-12

        <i id='W9USa'><tr id='W9USa'><dt id='W9USa'><q id='W9USa'><span id='W9USa'><b id='W9USa'><form id='W9USa'><ins id='W9USa'></ins><ul id='W9USa'></ul><sub id='W9USa'></sub></form><legend id='W9USa'></legend><bdo id='W9USa'><pre id='W9USa'><center id='W9USa'></center></pre></bdo></b><th id='W9USa'></th></span></q></dt></tr></i><div id='W9USa'><tfoot id='W9USa'></tfoot><dl id='W9USa'><fieldset id='W9USa'></fieldset></dl></div>
          <bdo id='W9USa'></bdo><ul id='W9USa'></ul>
          1. <small id='W9USa'></small><noframes id='W9USa'>

              <tbody id='W9USa'></tbody>
            <tfoot id='W9USa'></tfoot>

              1. <legend id='W9USa'><style id='W9USa'><dir id='W9USa'><q id='W9USa'></q></dir></style></legend>

                • 本文介绍了Robot Framework 中相互依赖的测试自动失败/不执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有大量的测试用例,其中几个测试用例是相互依赖的.是否有可能在执行稍后的测试用例时,您可以找出先前执行的测试用例的状态?就我而言,第 99 个测试用例取决于一些先前测试用例的状态,因此,如果第 24 个或第 38 个测试用例失败,我希望第 99 个测试用例根本不执行,从而节省大量时间.如果可能的话,请用一些例子来解释.提前致谢!

                  I have a large number of test cases, in which several test cases are interdependent. Is it possible that while a later test case is getting executed you can find out the status of a previously executed test case? In my case, the 99th test case depends on the status of some prior test cases and thus, if either the 24th or the 38th fails I would like the 99th test case NOT to get executed at all and thus save me a lot of time. Kindly, explain with some example if possible. Thanks in advance!

                  推荐答案

                  一旦机器人开始运行,就无法根据某些条件跳过测试.我认为这是机器人的弱点之一,但设计者似乎真的不喜欢跳过测试的概念.此外,没有一种内置方式可以让一个测试依赖于另一个测试.对此功能的功能请求被拒绝.

                  Once robot starts running, there's no way to skip a test based on some condition. I think this is one of the weaknesses of robot, but the designers really don't seem to like the notion of skipped tests. Also, there's no built-in way for one test to depend on another. A feature request for this very feature was declined.

                  然而,robot 是非常可扩展的,并且在 2.8.5 版本中引入的一个功能可以很容易地编写一个关键字,如果另一个测试失败了就会失败.这个功能是 充当监听器的库.有了这个,图书馆可以跟踪每个测试的通过/失败状态.有了这些知识,您可以创建一个在其他测试失败时立即失败的关键字.

                  However, robot is very extensible, and a feature that was introduced in version 2.8.5 makes it easy to write a keyword that will fail if another test has failed.This feature is the ability for a library to act as a listener. With this, a library can keep track of the pass/fail status of each test. With that knowledge, you can create a keyword that fails immediately if some other test fails.

                  基本思想是,在每次测试完成时缓存通过/失败状态(通过特殊的 _end_test 方法).然后,使用这个值来判断是否立即失败.

                  The basic idea is, cache the pass/fail status as each test finishes (via the special _end_test method). Then, use this value to determine whether to fail immediately or not.

                  以下是如何使用此类关键字的示例:

                  Here's an example of how to use such a keyword:

                  *** Settings ***
                  | Library | /path/to/DependencyLibrary.py
                  
                  *** Test Cases ***
                  | Example of a failing test
                  | | fail | this test has failed
                  
                  | Example of a dependent test
                  | | [Setup] | Require test case | Example of a failing test
                  | | log | hello, world
                  

                  这是库定义:

                  from robot.libraries.BuiltIn import BuiltIn
                  
                  class DependencyLibrary(object):
                      ROBOT_LISTENER_API_VERSION = 2
                      ROBOT_LIBRARY_SCOPE = "GLOBAL"
                  
                      def __init__(self):
                          self.ROBOT_LIBRARY_LISTENER = self
                          self.test_status = {}
                  
                      def require_test_case(self, name):
                          key = name.lower()
                          if (key not in self.test_status):
                              BuiltIn().fail("required test case can't be found: '%s'" % name)
                  
                          if (self.test_status[key] != "PASS"):
                              BuiltIn().fail("required test case failed: '%s'" % name)
                  
                          return True
                  
                      def _end_test(self, name, attrs):
                          self.test_status[name.lower()] = attrs["status"]
                  

                  这篇关于Robot Framework 中相互依赖的测试自动失败/不执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如果一个失败了,如何跳过课堂上的其余测试? 下一篇:如何发送带有损坏 FCS 的以太网帧?

                  相关文章

                  最新文章

                    <tfoot id='wC3bv'></tfoot>

                    1. <small id='wC3bv'></small><noframes id='wC3bv'>

                      <legend id='wC3bv'><style id='wC3bv'><dir id='wC3bv'><q id='wC3bv'></q></dir></style></legend>
                        <bdo id='wC3bv'></bdo><ul id='wC3bv'></ul>
                      <i id='wC3bv'><tr id='wC3bv'><dt id='wC3bv'><q id='wC3bv'><span id='wC3bv'><b id='wC3bv'><form id='wC3bv'><ins id='wC3bv'></ins><ul id='wC3bv'></ul><sub id='wC3bv'></sub></form><legend id='wC3bv'></legend><bdo id='wC3bv'><pre id='wC3bv'><center id='wC3bv'></center></pre></bdo></b><th id='wC3bv'></th></span></q></dt></tr></i><div id='wC3bv'><tfoot id='wC3bv'></tfoot><dl id='wC3bv'><fieldset id='wC3bv'></fieldset></dl></div>