You're right, the only way to do this is via System.properties. What I was
looking for was a way to set the System.properties for the Junit test from
within jmeter rather than having to do it globally. At the moment, using jmeter
system.properties each test will see the same set of values. What I'd like to
do is change it so that each test can have it's individual system.properties
set just before it's invoked.
I've hacked the Junit sampler so that it does this so far
public SampleResult sample(Entry entry) {
PropertyIterator iterator = this.propertyIterator();
while(iterator.hasNext())
{
JMeterProperty property= iterator.next();
System.setProperty(property.getName(),
property.getObjectValue().toString());
}
This gets the alll the properties around available to the junit.
I was wondering if by using eg. a csv file I could do some more interesting
stuff e.g. each line in the csv file was a new set of test properties and these
could be set so that the thread group for the producer could run and each call
to the junit got the next line in the csv file as a property name. e.g.
csv =
1,2
2,3
3,4
thread group and thus junit first time round go the system properties
NUMBER_OF_MESSAGES=1 & SIZE_OF_MESSAGES=2. the second time round the values
were 2, 3 etc.
It look like JMeter gets close to this but I haven't sat down and looked at
what it looks like in the code yet to hack it into the junit sampler.
what do you think?
On 16/04/2008, John Hawkins <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Not quite sure what you're asking me so I'll tell you my scenario...
>
> I have a test-plan which has two thread groups. each thread group has a
> JUnit request in it one thread group is a producer Junit request and the
> other a consumer Junit request. I'd like to pass in some global properties so
> that they both see them; for instance, how many messages to send and how big
> the messages should be I would like the consumer and producer JUnit tests to
> be able to pick up these variables (e.g. using system.getProperty() )and
> change their behaviour accordingly. I can then use the same producer and
> consumer junit classes for the same tests just with different parameters for
> the message size and number of messages.
>
> I can see that I can set variables in various ways but I can't see any doc
> that says that they'll get seen by the junit tests themselves.
>
JUnit tests won't have access to JMeter properties, nor will they have
access to JMeter variables.
However, if you set System properties they will be visible to all code.
> If there's a better way to do this then I'm all ears. To be honest I'm
> struggling with the concepts here.
If you were not using JMeter, how would you pass parameters to the JUnit tests?
As far as I know, there is no way to pass values to JUnit tests except
via properties - or perhaps files.
> many thanks,
> John.
>
>
>
> sebb <[EMAIL PROTECTED]>
> 16/04/2008 11:13
> Please respond to
> "JMeter Users List" <[email protected]>
>
> To
> "JMeter Users List" <[email protected]>
> cc
>
> Subject
> Re: junit sampler accepting variables
>
>
>
>
>
>
>
> On 16/04/2008, John Hawkins <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> >
> > I mean so that the junit test can pick up system.properties that have
> been set in a user defined variables "node"? It would also be useful if the
> junit could pick up variables from the testplan level user defined variables.
> >
> But which parameters on the JUnit sampler GUI need to be able to pick
> up these variables?
> > cheers,
> >
> > John.
> >
> >
> >
> > On 15/04/2008, John Hawkins <[EMAIL PROTECTED]> wrote:
> > > hi,
> > >
> > > I saw on a 2006 mail that the Junit sampler can't take in variables
> e.g. from user defined variables. This would be a really useful thing in
> order to be able to re-use tests with different parameters.
> > Which parameters are you referring to?
> > > Has this function been put in since?
> > >
> > > cheers,
> > > John.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]