testng-dataprovider

Posted shilimaixiang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了testng-dataprovider相关的知识,希望对你有一定的参考价值。

  • 基于ITestContext实现dataprovider的时候,直接在ran as testng一直提示失败,获取groups的长度竟然是0,头大技术图片
  • 原来基于ITestContext的时候,是要用testng.xml文件来实现的,那就加一个xml文件技术图片

  • 可是按上图执行,groups2获取到的dataprovider 还是groups1的,原来要分开,每一个groups一个test
  • 这样才行
  • 技术图片

     

 别人给的解释:If you directly run your testng class, it will first call dataprovider which cant get groups information as groups are not available. But instead if you call this class via testng.xml, it will have groups info available with ITestContext.

以上是关于testng-dataprovider的主要内容,如果未能解决你的问题,请参考以下文章