是否可以将TestNG数据提供者数据从测试传递到@aftermethod拆解

时间:2016-01-07 21:02:40

标签: testng testng-dataprovider

类似的东西:

@Test(groups = {"eventAdmin"}, dataProvider="EventAdminProvider",   
     dataProviderClass= EventAdminCurationDataproviderClass.class)
public void EventCurationclearFilter(String eventName) throws Exception {

@AfterMethod(groups={"eventAdmin"})
public void teardown(String eventName) throws Exception {

1 个答案:

答案 0 :(得分:2)

是,但不像SET pf=%ProgramFiles% if DEFINED ProgramFiles(x86) SET pf=%ProgramFiles(x86)% set appcmd="%pf%\iis express\appcmd.exe" set iisexpress="%pf%\iis express\iisexpress.exe" cd > tmpFile set /p currentdir= < tmpFile del tmpFile where php-cgi.exe > tmpFile set /p phprt= < tmpFile del tmpFile if DEFINED phprt goto setup_iis SET phprt=%pf%\PHP\v5.3\php-cgi.exe :setup_iis %appcmd% set config /section:system.webServer/fastCgi "/+[fullPath='%phprt%']" "/apphostconfig:%currentdir%\applicationhost.config" %appcmd% set config /section:system.webServer/handlers "/+[name='PHP-FastCGI',path='*.php',modules='FastCgiModule',verb='*', scriptProcessor='%phprt%',resourceType='Either']" "/apphostconfig:%currentdir%\applicationhost.config" %iisexpress% /site:EmptySite /config:"%currentdir%\applicationhost.config" 那样直接。您可以使用native dependency injection获取传递给测试的参数数组。我看到两种方法:

  1. 使用@Test

    ITestResult
  2. 使用@Test(groups = {"eventAdmin"}, dataProvider = "EventAdminProvider", dataProviderClass = EventAdminCurationDataproviderClass.class) public void EventCurationclearFilter(String eventName) throws Exception { /* Your test code using `eventName` here. */ } @AfterMethod(groups = {"eventAdmin"}) public void teardown(ITestResult result) throws Exception { String eventName = (String) result.getParameters()[0]; /* Your teardown code using `eventName` here. */ }

    Object[]
相关问题