How to pass parameters with changing values?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to pass parameters with changing values?

tarun3kumar

My program is as follows:

for int (i=0;i<=5;i++)
    load i.xml
    for int (j=0;j<=9;j++)
        Map mp = new Map();
        mp.add(parameter test[i].value[j])
    validate(mp)

The parameters in the properties file look like:

test1.value1=
test1.value2=
test1.value3=

test2.value1=
test2.value2=
test2.value3=

test3.value1=
test3.value2=
test3.value3=

As you can see the names of the parameters are the same,except for the prefix but their value changes. This program runs in a loop (as the syntax shows). My question how can such parameter passing be achieved. I cannot generate the values inside the program. They have to be an external input. Not only that, this list can grow or reduce dynamically.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=66164&messageID=126222#126222


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters with changing values?

Cédric Beust ♔
Why not use a @DataProvider which will read the file and read the correct values, regardless of how the parameter names change, and then return these values so they can be passed to your test method?

--
Cedric


On 2/21/07, magnatron <[hidden email]> wrote:

My program is as follows:

for int (i=0;i<=5;i++)
    load i.xml
    for int (j=0;j<=9;j++)
        Map mp = new Map();
        mp.add(parameter test[i].value[j])
    validate(mp)

The parameters in the properties file look like:

test1.value1=
test1.value2=
test1.value3=

test2.value1=
test2.value2=
test2.value3=

test3.value1=
test3.value2=
test3.value3=

As you can see the names of the parameters are the same,except for the prefix but their value changes. This program runs in a loop (as the syntax shows). My question how can such parameter passing be achieved. I cannot generate the values inside the program. They have to be an external input. Not only that, this list can grow or reduce dynamically.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=66164&messageID=126222#126222


--
Cédric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters with changing values?

Alexandru Popescu ☀
In reply to this post by tarun3kumar

On 2/21/07, magnatron <[hidden email]> wrote:

>
> My program is as follows:
>
> for int (i=0;i<=5;i++)
>     load i.xml
>     for int (j=0;j<=9;j++)
>         Map mp = new Map();
>         mp.add(parameter test[i].value[j])
>     validate(mp)
>
> The parameters in the properties file look like:
>
> test1.value1=
> test1.value2=
> test1.value3=
>
> test2.value1=
> test2.value2=
> test2.value3=
>
> test3.value1=
> test3.value2=
> test3.value3=
>
> As you can see the names of the parameters are the same,except for the prefix but their value changes. This program runs in a loop (as the syntax shows). My question how can such parameter passing be achieved. I cannot generate the values inside the program. They have to be an external input. Not only that, this list can grow or reduce dynamically.

I don't have enough details to suggest a solution, but I would
probably try to load the external data inside a @DataProvider and use
this one to feed my @Test method.

Just a wild guess,

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How to pass parameters with changing values?

tarun3kumar
In reply to this post by tarun3kumar

Will give that a try. I was also thinking on the same lines. Just wanted to confirm the strategy.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=66164&messageID=126580#126580


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---