Pass parameter variables from bean.xml to TestNG as a list

Skip to first unread message

Pavao Lukušić

May 27, 2021, 2:29:39 PM5/27/21
to testng-dev

I am fairly new in writing TestNG test cases and was wondering if there is a possibility to pass "object like" parameters in bean file to the test part?

For example: In bean file I have :

<parameter name="movieType1" value="Horror" /> 
<parameter name="numberOfMovies" value="150" /> 
<parameter name="totalEarnings" value="365789764" />
 <parameter name="movieType2" value="Action" /> 
<parameter name="numberOfMovies2" value="365555" />
 <parameter name="totalEarnings2" value="879784545642132" /> 

 more movie types, etc

Is there a way to create ban file in which I can pass variables as some kind of list of some class, like :
                      <name value=horror> 
                      <numberOfMovies value=150> 
                       <total earnings value=365789764> 
                      <name value=aciton> 
                      <numberOfMovies value=365555> 
                      <total earnings value=879784545642132>
I know I can get each parameters in code like this :
@BeforeSuite @Parameters({ "movieType1", "numberOfMovies" , "totalEarnings", etc..}) private void beforeSuite(String movieType1, String numberOfMovies, String totalEarnings)

But what if I would like to enter 100 of movie types? I would need to write all variables (movieType1 ... MovieType100) inside of @Parameters tag ?

Is there a smarter way to pass those elements? (I really need to pass it from bean.xml file)

Any help would be really appreciated.

⇜Krishnan Mahadevan⇝

May 28, 2021, 2:02:46 AM5/28/21
Are these parameters intended to be used by test methods or configurations ?

If they are test methods, then you can very well leverage a data provider ("@DataProvider") and have it feed off of the bean.xml file and work with it.

If they are configuration methods, then I am not sure if you have a lot of options.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @
My Technical Scribblings @

You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages