【问题标题】:TestNG :- not able to get context.getCurrentXmlTest()TestNG :- 无法获取 context.getCurrentXmlTest()
【发布时间】:2015-03-19 08:19:59
【问题描述】:

我还有一些其他测试上下文,其中包含要导入和读取的自定义逻辑 “测试配置文件”

但是

@DataProvider(name = "testdata")
    public Object[][] testdata(ITestContext context) {
        Map<String, String> parameters = context.getCurrentXmlTest()
                .getAllParameters();
        System.out.println("-------");

        Iterator it = parameters.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry pairs = (Map.Entry) it.next();

            String x = (String) pairs.getValue();

            if (x.startsWith("created_")
                    && !pairs.getKey().toString().contains("shareData")) {
                String y = (String) universalMap.get(x);
                parameters.put((String) pairs.getKey(), y);
            }
        }
        return new Object[][] { { parameters } };
    }

它无法检测到 context 有一个 getCurrentXmlTest() 方法,即使在类型转换为

之后也是如此
Map<String, String> parameters = (((ITestContext)context).getCurrentXmlTest())
                .getAllParameters();

仍然会抛出:-

The method getCurrentXmlTest() is undefined for the type ITestContext

【问题讨论】:

    标签: java unit-testing automated-tests integration-testing testng


    【解决方案1】:

    哦,我使用的是非常旧的 testng-5.4-jdk15.jar TestNG 库。

    现在,我已经升级了它,现在可以正常工作了。

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-19
      相关资源
      最近更新 更多