• <small id='WgL68'></small><noframes id='WgL68'>

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

          <bdo id='WgL68'></bdo><ul id='WgL68'></ul>

        TestNG retryAnalyzer 仅在方法@Test 中定义时有效,在

        时间:2023-10-01

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

          <tbody id='sstzu'></tbody>
          <bdo id='sstzu'></bdo><ul id='sstzu'></ul>

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

                  本文介绍了TestNG retryAnalyzer 仅在方法@Test 中定义时有效,在类@Test 中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这按预期工作,测试失败(由于 haltTesting())并重复 2 次

                  This works as supposed, test fails (due to haltTesting()) and is repeated 2x

                  public class A0001_A0003Test extends TestControl {
                  
                      private Kunde kunde = Kunde.FR_WEHLITZ;
                  
                      @Test(retryAnalyzer = TestRepeat.class, groups = {TestGroups.FAILED}, description = "verify adress")
                      public void testkundenDaten_Angaben() throws Exception {
                          bifiTestInitial();
                          testActions.selectKunde(kunde);
                          haltTesting();
                      }
                  } 
                  

                  但是因为我在一个班级中有多个测试,所以我在班级级别定义了 repeatAnalyzer

                  but because i have multiple tests in one class, i defined the repeatAnalyzer on class level

                  @Test(retryAnalyzer = TestRepeat.class)
                  public class A0001_A0003Test extends TestControl {
                  
                      private Kunde kunde = Kunde.FR_WEHLITZ;
                  
                      @Test(groups = {TestGroups.FAILED}, description = "verify adress")
                      public void testkundenDaten_Angaben() throws Exception {
                          bifiTestInitial();
                          testActions.selectKunde(kunde);
                          haltTesting();
                      }
                  } 
                  

                  但是没有重复测试,文档说:

                  but then the test is not repeated, the documentation says:

                  一个类级别的@Test注解的作用是使所有的此类的公共方法成为测试方法,即使它们是没有注释.您仍然可以在方法上重复 @Test 注释如果你想添加某些属性.

                  The effect of a class level @Test annotation is to make all the public methods of this class to become test methods even if they are not annotated. You can still repeat the @Test annotation on a method if you want to add certain attributes.

                  所以这应该是可能的,还是我期待错误的结果?

                  So it should have been possible or am I expecting the wrong outcome?

                  推荐答案

                  我的解决方案是为 @BeforeSuite 方法中的所有方法设置一个 retryAnalyzer.但是不要在 beforeMethod 中设置它,因为这样每次调用都会重新创建一个新的计数器 => 无限循环.

                  My solution was to set a retryAnalyzer for all methods in the @BeforeSuite method. But do not set it in beforeMethod because then it will be re-created each invocation with a new counter => endless loop.

                  @BeforeSuite(alwaysRun = true)
                  public void beforeSuite(ITestContext context) {
                       TestRepeat testRepeat = new TestRepeat();
                       for (ITestNGMethod method : context.getAllTestMethods()) {
                           method.setRetryAnalyzer(testRepeat);
                       }
                  }
                  

                  这篇关于TestNG retryAnalyzer 仅在方法@Test 中定义时有效,在类@Test 中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在套件级别上并行运行 JUnit 测试? 下一篇:为 Web 应用程序选择 java 自动化测试工具

                  相关文章

                  最新文章

                      <legend id='scSbZ'><style id='scSbZ'><dir id='scSbZ'><q id='scSbZ'></q></dir></style></legend><tfoot id='scSbZ'></tfoot>

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

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