Is a TestNG data provider parameter in setUp method possible? -
i have init statements need done data provider parameter , want access data provider parameter value in @beforemethod
setup method. possible?
yes, totally possible. in @beforemethod
annotated method, can pass optional built-in argument of object[] copy of parameters being passed @test
method. in case, pass 2 args test method:
@test(dataprovider="provider") public void dotest( testhelper testhelper, map<string,string> parammap ) { ....
so, (and doesn't need factory dataprovider) :
@beforemethod public void setup( object[] testargs ) { map<string,string> parammap = (map<string, string>)testargs[1]; testhelper testhelper = testargs[0]; string testname = parammap.get( "testcasename" ); log.logtcstep( "test case name: " + testname ); log.setlogtcname( testname ); testhelper.settestname( testname ); testhelper.settagsbystring( parammap.get( "browser" ) ); testhelper.setbuildnumber( parammap.get( "environment" ) ); }
Comments
Post a Comment