【问题标题】:Using IAnnotationTransformer outside testng.xml在 testng.xml 之外使用 IAnnotationTransformer
【发布时间】:2020-10-21 21:47:42
【问题描述】:

据我了解,IAnnotationTransformer 类在套件启动之前运行,因此它不能像 ITestListener 那样在类级别上声明。所以我经常看到的这个用法是将它添加到 testng.xml 文件中:

<suite name = "testSuite" >

    <listeners>
        <listener class-name="TestAnnotationTransformer" />
    </listeners>

(...)


但是,有时我需要从 IDE 运行测试:right-click -&gt; Run As -&gt; TestNG Test,因此在执行此操作时,将运行 testng-customsuite.xml 文件,其中不包含声明的侦听器。

我知道我可以通过 Eclipse 为 TestNG 设置一个模板 xml 文件,但是由于团队中有一些人在使用 IntelliJ,我想避免这样做。

我的问题是:如何确保始终执行 IAnnotationTransformer,无论我如何执行测试或使用哪个 IDE?

【问题讨论】:

    标签: java eclipse testng


    【解决方案1】:

    TestNg 的更改说明表明,如果您使用的是 6.9.10 或更高版本,则 IAnnotationTransformer 支持 @Listeners。

    【讨论】:

      猜你喜欢
      • 2014-09-10
      • 2021-07-10
      • 2015-08-03
      • 2018-01-12
      • 1970-01-01
      • 2019-06-09
      • 1970-01-01
      • 2012-08-10
      • 2015-07-27
      相关资源
      最近更新 更多