gpt4 book ai didi

java - TestNG "getCurrentXmlTest()).getAllParameters()"API 使用非常旧的 testng-5.4-jdk15.jar TestNG 库

转载 作者:行者123 更新时间:2023-12-02 03:38:42 27 4
gpt4 key购买 nike

出于某种原因,我必须使用旧的 TestNG 库,它没有 "getCurrentXmlTest()).getAllParameters()" API

我应该如何使用testng-5.4-jdk15.jar获取所有TestXML参数

对于最新的 TestNG 版本,这是我们获取所有参数的方式,但是我如何使用 testng-5.4-jdk15.jar 模拟这样的代码

@DataProvider(name = "DataFile")
public Object[][] testdata(ITestContext context) {
Map<String, String> parameters = (((ITestContext)context).getCurrentXmlTest())
.getAllParameters();
return new Object[][] { { parameters } };
}

附注:- 我无法升级 jar :(

最佳答案

从 TestNG 5.5 源(因为 5.4 源和二进制文件在 Maven Central 上不可用),以下内容应该有效:

Map<String, String> parameters = (((TestRunner)context).getTest()).getParameters();

关于java - TestNG "getCurrentXmlTest()).getAllParameters()"API 使用非常旧的 testng-5.4-jdk15.jar TestNG 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37132322/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com