我想通过侦听器类为 BeforeSuite 方法设置一些超时。我找不到这方面的帮助。(我正在使用Selenium WebDriver( 我有很多测试套件,我们已经为每个测试设置了超时,并希望限制 BeforeSuite 方法的时间。 我想通过侦听器设置它,而不是将其添加到每个套件中。
@BeforeSuite(groups = {"aa-bb-cc"})
public void abcdef(ITestContext context) throws Exception {
....}
@AfterSuite(groups = {"aa-bb-cc"})
public void cleanup() {
quitDriver();
}
如何使用侦听器为上述 2 种方法设置超时(而不是像 @BeforeSuite(组 = {"aa-bb-cc"},timeOut=600000(那样硬编码超时(
您可以使用 org.testng.IAnnotationTransformer2
文档 Java Doc IAnnotationTransformer2
如果需要,请使用此接口而不是 IAnnotationTransformer 修改除@Test之外的任何 TestNG注释。
您将需要覆盖具有参数的方法 IConfiguration注释
@Override
public void transform(IConfigurationAnnotation annotation, Class testClass,
Constructor testConstructor, Method testMethod) {
annotation.setTimeOut(10);
}